出於某種原因,當我想要的所有內容都從member_details表中返回時,所有行都返回等於下拉列表中所選項目的單個行。在php中列出1行而不是所有行
下面是它的PHP:我認爲它會返回等於下拉值的行,但它只是列出它的一切。
<?php
if (isset($_POST['members'])) {
$ResultSet = getTableResults("member_details");
echo "<h1> Member Details </h1>";
echo "<table border='1' cellpadding='6'>";
echo "<tr> <th>Id</th> <th>Name</th> <th>Job</th> <th>Wage</th> <th>Hobby</th> ";
foreach ($ResultSet as $row) {
echo "<tr>";
echo "<td>" . $row ['member_id'] . "</td>";
echo "<td>" . $row['first_name'] . " " . $row ['second_name'] . "</td>";
echo "<td>" . $row['job'] . "</td>";
echo "<td>" . $row['wage'] . "</td>";
echo "<td>" . $row['hobby'] . "</td>";
echo "</tr>";
}
echo "<table>";
}
?>
如果你想看到更多的代碼,更有意義的是,請要求和IL編輯和更新的問題。
function getTableResults() {
$sql = "SELECT DISTINCT member_details.member_id, members.first_name, members.second_name, member_details.wage, member_details.job, member_details.hobby
FROM members
INNER JOIN member_details
ON members.member_id=member_details.member_id";
$mysqlConnection = getSQLConnection();
$ResultSet = $mysqlConnection->query($sql);
return $ResultSet;
}
是的,我們需要看看'getTableResults()'代碼 –
'getTableResults'是那裏唯一與數據庫相關的代碼。這是什麼框架或圖書館? – JAL
我正在使用netbeans for php並使用wamp和phpmyadmin –