我在php中创建了一个关于教师和学生数据库的网站,我已经在mysql数据库中完成了几乎所有的事情,但是我想从表中提取特定数据,就像我想从栏目“名称”中选择“prof。vaidya sir”并显示教授相关的所有数据。如何从php/mysql中的不同表中获取特定列数据
这里是我的代码:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<?php
include 'dbh.php';
$name = "Prof. Vaidya Sir";
$class ="BE";
$sqll = "SELECT feedback1.erp,feedback1.class,feedback2.name,feedback2.ability,feedback2.knowledge,feedback2.accessbility,feedback2.attitude FROM feedback1, feedback2 WHERE feedback1.erp=feedback2.erp";
$result = $conn->query($sqll);
?>
<table border="2">
<thead>
<tr><th>erp</th><th>class</th><th>name</th><th>ability</th><th>knowledge</th><th>accessbility</th><th>attitude</th></tr>
</thead>
<tbody>
<?php
if($result->num_rows > 0)
{
while ($row = $result->fetch_assoc()){
echo "<tr><td>{$row["erp"]}</td><td>{$row["class"]}</td><td>{$row["name"]}</td><td>{$row["ability"]}</td><td>{$row["knowledge"]}</td><td>{$row["accessbility"]}</td><td>{$row["attitude"]}</td></tr>\n";
}
else{echo "0 results";
}
?>
</tbody>
</table>
</body>
</html>
这是上面的代码输出
您需要使用特定的'WHERE'和'AND'。 –
你要求帮助,你已经以下面给出的答案给出了答案。你可以接受你想要的,或者发表评论,看它是否适合你。如果您仅仅在未来的日期留下问题并且不让他们知道它是否有效,那么这不是一个好策略。 –
谢谢你的帮助,它显示教授。 vaidya先生相关的两行,但也显示1警告 - 警告:错误的参数计数为mysqli_stmt :: bind_param()在C:\ xampp \ htdocs \ sitea \ feedback_out.php第21行对象(mysqli_result)#3(5){[ “current_field”] => int(0)[“field_count”] => int(7)[“length”] => NULL [“num_rows”] => int(2)[“type”] => int(0 )} –