搜索过滤器继续

时间:2013-03-19 09:37:34

标签: php database search username

这是我到目前为止所拥有的。 search_db.php现在将用户字段显示为超链接,这很棒,当链接被跟踪时,我没有搜索结果。

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>";
?>

我在userDetails.php中尝试了不同的查询变体,但是无法让它显示我的过滤结果

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 个答案:

答案 0 :(得分:0)

您需要替换下面的查询,

<强>替换

$data = mysql_query("SELECT * FROM mordred13 WHERE user='user'");

<强>与

$data = mysql_query("SELECT * FROM mordred13 WHERE id ='".$_REQUEST['userID']."'");