根据 ID 从表中获取特定行 [英] Get specific row from table based on ID
本文介绍了根据 ID 从表中获取特定行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想从带有 id 的表中获取特定行.我的表有 5 列名为:id、title、active、position、content
例如,如果我给 id 5,那么数据库必须给我 ID = 5 的行
现在我有了这个
$result = mysql_query("SELECT * FROM klant1");
$contents = mysql_fetch_array($result);$rows = mysql_num_rows($result);for($i = 0; $i <= $rows - 1; $i ++){echo "";echo "";echo "";echo "<td>标题</td><td>活动</td><td>删除</td><td>位置</td><td></td>tr></table>";echo "<table id='sub'><tr><td>Menu</td>";echo "<td><input style='float: left;'type='checkbox'/></td>";echo "<td><img style='height:11px;'src='img/delete.png'/></td>";echo "<td><select><option value='1'>1</option></select></td>";echo "<td><img style='float: right; height: 20px;'src='img/save.png'/></td>";echo "</tr></table> </div>";}我想更改当前行右侧标题中的标题等关键字.
顺便说一句,抱歉我的英语不好
解决方案 添加 WHERE 并使用 PDO.mysql_query
已弃用.
$pdo = new PDO(...);$statement = $pdo->prepare("SELECT * FROM klant1 WHERE id = ?");$statement->bindParam(1, $id);$statement->execute();
I want to get a specific row from a table with an id.
My table has 5 columns named: id, title, active, position, content
for example, if i give id 5 then the database must give me the row where ID = 5
now i have this
$result = mysql_query("SELECT * FROM klant1");
$contents = mysql_fetch_array($result);
$rows = mysql_num_rows($result);
for($i = 0; $i <= $rows - 1; $i ++){
echo "<div id='block'>";
echo "<table id='titleTab'>";
echo "<tr id='title'>";
echo "<td>Title</td><td>Active</td><td>Remove</td><td>Position</td><td></td></tr></table>";
echo "<table id='sub'><tr><td>Menu</td>";
echo "<td><input style='float: left;' type='checkbox'/></td>";
echo "<td><img style='height:11px;'src='img/delete.png'/></td>";
echo "<td><select><option value='1'>1</option></select></td>";
echo "<td><img style='float: right; height: 20px;' src='img/save.png'/></td>";
echo "</tr></table> </div>";
}
I want to change keywords such as Title in the right title of the current row.
Sorry for my bad english by the way
解决方案 Add a WHERE and use PDO. mysql_query
is deprecated.
$pdo = new PDO(...);
$statement = $pdo->prepare("SELECT * FROM klant1 WHERE id = ?");
$statement->bindParam(1, $id);
$statement->execute();
这篇关于根据 ID 从表中获取特定行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文
登录
关闭
扫码关注1秒登录
发送“验证码”获取
|
15天全站免登陆