搜索过滤器继续 [英] Search filter continued

查看:125
本文介绍了搜索过滤器继续的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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

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中尝试了查询的不同变体,但无法显示我筛选的结果

I have tried different variations of the query in userDetails.php but just can't get it to show my filtered results

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


推荐答案

您需要替换以下查询,

替换

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

with

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

这篇关于搜索过滤器继续的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆