-2
即時通訊新的php!我目前顯示來自MySQL的數據,每次我搜索名稱或ID號,並顯示所有的HTML表,但是當我點擊錶行上的按鈕時,我得到的數據的最後一個值。td值到mysql
這裏是我做的代碼:
$searchdata=mysql_query("select * from tblstudent where Last_name
='".$search."'")or die("Error Query");
if(isset($_POST['Search'])){
if(empty($search)){
$error_2="Search Box is empty";
}
elseif(strlen($search)<1){
$error_2="ERROR SEARCH";
}
else{
//display data to the table
echo "<div id='res'><form id='form1' method='POST' action=".basename(__FILE__).">
Reservation Fees:<input id='descriptive' name='reserv' type='text' /> ";
echo "<table id='example' border='1'>
<tr>
<th>ID NUMBER</th>
<th>LAST NAME</th>
<th>FIRST NAME</th>
<th>MIDDLE NAME</th>
<th>COURSE</th>
<th>GENDER</th>
</tr>";
while($row=mysql_fetch_array($searchdata)){
$studentid=$row['student_id'];
$coursee=$row['Course'];
$lnamee=$row['Last_name'];
$fnamee=$row['First_name'];
$mnamee=$row['M_name'];
$gnder=$row['Gender'];
echo "
<tr>
<td>".$studentid." <input type='hidden' name='dummyID' value='$studentid'></td>
<td>".$lnamee." <input type='hidden' name='dummylname' value='$lnamee'></td>
<td>".$fnamee."<input type='hidden' name='dummyfname' value='$fnamee'></td>
<td>".$mnamee."<input type='hidden' name='dummymname' value='$mnamee'></td>
<td>".$coursee."<input type='hidden' name='dummycourse' value='$coursee'></td>
<td>".$gnder."<input type='hidden' name='dummygnder' value='$gnder'></td>
<td><input id='send' name='add' type='submit' value='Reserve' /></td>
</tr>";
}
echo "</table>
</form></div>";
}}}
你知道它是不是安全的MySQL對注射?你也應該看起來像。爲了更好的搜索查詢:) 此外,我真的不明白你的問題是什麼。 – Sietse
你有沒有在你的phpmyadmin中運行該查詢?我認爲你的邏輯是正確的。 – diEcho
@Sietse抱歉,我不知道在mysql中不安全,我很抱歉我提出的問題!我想說的是,我每次搜索就像兩個親戚姓氏出現在表學生的姓時的每一次點擊的TD之一,它顯示了