2013-03-19 122 views
1

这就是我迄今为止所拥有的。 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>"; 
?> 

回答

0

您需要替换如下查询,

更换

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

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

我认为这个问题是我没有唯一ID字段集。我正在使用用户字段。 – 2013-03-19 10:02:51

+0

@PaulHesketh ohh不...你在前面的问题中告诉我兄弟...所以只传递每个用户独特的字段值... – 2013-03-19 10:09:36

+0

全部完成,你是一个传奇谢谢你,谢谢,谢谢 – 2013-03-19 10:12:24