2013-03-19 123 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