我在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 )} –