问题
This is what I have so far. The search_db.php now shows the user field as hyperlinks which is great, when the links are followed I get no search results.
search_db.php
$term = $_POST['term'];
$data = mysql_query("select * FROM mordred13 WHERE alliance like '%$term%' ORDER BY alliance, might DESC");
echo "<table border='1' cellpadding='5'>";
echo "<tr> <th>Alliance</th> <th>User</th> <th>Might</th>";
// loop through results of database query, displaying them in the table
while($row = mysql_fetch_array( $data )) {
// echo out the contents of each row into a table
echo "<tr>";
echo '<td>' . $row['alliance'] . '</td>';
echo '<td><a href="userDetail.php?userID='.$row['id'].'">' . $row['user'] . '</td>';
echo '<td>' . $row['might'] . '</td>'
echo "</tr>";
}
// close table>
echo "</table>";
?>
I have tried different variations of the query in userDetails.php but just can't get it to show my filtered results
userDetails.php
$term = $_POST['term'];
$data = mysql_query("SELECT * FROM mordred13 WHERE user='user'");
echo "<table border='1' cellpadding='5'>";
echo "<tr> <th>Alliance</th> <th>User</th> <th>Might</th>";
// loop through results of database query, displaying them in the table
while($row = mysql_fetch_array( $data )) {
// echo out the contents of each row into a table
echo "<tr>";
echo '<td>' . $row['alliance'] . '</td>';
echo '<td>' . $row['user']
echo '<td>' . $row['might'] . '</td>'
echo "</tr>";
}
// close table>
echo "</table>";
?>
回答1:
You need to replace query as below,
Replace
$data = mysql_query("SELECT * FROM mordred13 WHERE user='user'");
with
$data = mysql_query("SELECT * FROM mordred13 WHERE id ='".$_REQUEST['userID']."'");
来源:https://stackoverflow.com/questions/15495844/search-filter-continued