0
我正在製作一個名單和鏈接到他們的完整信息列表。所以,我有一個簡單的搜索引擎,通過名稱或具體數字進行搜索。我使用$ _SESSION來獲取人員的ID。問題是,當有超過1個名字,並且移動到特定人員的頁面時,出現列表中最後一個人的頁面! 所以,搜索引擎的代碼是:如何製作鏈接列表?
if(isset($_POST['search'])){
$searchq = $_POST['search'];
$searchq = preg_replace("#[^0-9_a-z A-Z]#i","",$searchq);
$query = mysql_query("SELECT * FROM contract WHERE name LIKE '%$searchq%' OR student_code LIKE '%$searchq%'") or die("could not search");
$count = mysql_num_rows($query);
if($count == 0){
$output = 'There was no such results!';
}
else{
while($row = mysql_fetch_array($query)){
$name = $row['name'];
$student_code = $row['student_code'];
$_SESSION['users_id'] = $row['users_id'];
$output = '<table border ="1"><tr><td>'.$name.' '.$student_code.'
</td>
<td>
<form action="cont.php" method="post">
<label>Look at the contract:</label>
<input type="submit" name="submit" value=">>">
</form>
</td>
</tr>
</table><br \>
,並在頁面文件中的另一個腳本:
$users_id = $_SESSION['users_id'];
$result = mysql_query("SELECT * FROM contract WHERE users_id = $users_id");
while($myrow = mysql_fetch_array($result)){
$output1 =
是的,現在有用!謝謝! – iacm 2014-11-22 14:52:52
@iacm可愛!你明白了爲什麼?讓我知道如果你需要更深入的解釋:) – ILOABN 2014-11-22 15:51:00
是的,我明白了,現在我甚至在項目的另一部分修復了更多的錯誤,都感謝你:D – iacm 2014-11-22 16:15:49