prepare('SELECT us-6ren">
gpt4 book ai didi

php - 使用PDO使用php从mysql数据库中提取特定值

转载 作者:行者123 更新时间:2023-11-29 11:00:04 24 4
gpt4 key购买 nike

这是我正在使用的 PHP 代码。我想从数据库中仅提取 userProfession = "Teacher"的详细信息,如何实现?

$stmt = $DB_con->prepare('SELECT userID, userName, userProfession, userPic FROM tbl_users ORDER BY userID DESC');
$stmt->execute();

if($stmt->rowCount() > 0)
{
while($row=$stmt->fetch(PDO::FETCH_ASSOC))
{
extract($row);
?>
<div class="col-xs-3">
<p class="page-header"><?php echo $userName."&nbsp;/&nbsp;".$userProfession; ?></p>
<img src="user_images/<?php echo $row['userPic']; ?>" class="img-rounded" width="250px" height="250px" />
<p class="page-header">
<span>
<a class="btn btn-info" href="editform.php?edit_id=<?php echo $row['userID']; ?>" title="click for edit" onclick="return confirm('sure to edit ?')"><span class="glyphicon glyphicon-edit"></span> Edit</a>
<a class="btn btn-danger" href="?delete_id=<?php echo $row['userID']; ?>" title="click for delete" onclick="return confirm('sure to delete ?')"><span class="glyphicon glyphicon-remove-circle"></span> Delete</a>
</span>
</p>
</div>

最佳答案

SELECT userID, userName, userProfession, userPic FROM tbl_users WHERE userProfession = "Teacher" ORDER BY userID DESC

就是你所需要的。

关于php - 使用PDO使用php从mysql数据库中提取特定值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42421843/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com