Search filter continued

心已入冬 提交于 2019-12-24 07:09:25

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!