我在用mysql創建一個表單。 當用戶輸入新數據時,該數據將自動保存到數據庫中,並在需要時顯示瀏覽器。此表單用於在瀏覽器中顯示mysql數據。顯示在瀏覽器中的第一行的最後一項
一切正常。但是當用戶提交數據,然後顯示最後一個數據時,我的問題是什麼。但我需要先在瀏覽器中顯示這些細節。
<?PHP
$connection=Mysql_connect('xxxresource.com','xxx','xxxx');
if(!$connection)
{
echo 'connection is invalid';
}
else
{
Mysql_select_db('tions',$connection);
}
//check if the starting row variable was passed in the URL or not
if (!isset($_GET['startrow']) or !is_numeric($_GET['startrow'])) {
//we give the value of the starting row to 0 because nothing was found in URL
$startrow = 0;
//otherwise we take the value from the URL
} else {
$startrow = (int)$_GET['startrow'];
}
//this part goes after the checking of the $_GET var
$fetch = mysql_query("SELECT * FROM customer_details LIMIT $startrow, 10")or
die(mysql_error());
$num=Mysql_num_rows($fetch);
if($num>0)
{
echo "<table margin=auto width=999px border=1>";
echo "<tr><td><b>ID</b></td><td><b>Name</b></td><td><b>Telephone</b></td><td> <b>E-mail</b></td><td><b>Couttry Applying for</b></td><td><b>Visa-Category</b> </td><td><b>Other Category</b></td><td><b>Passport No</b></td><td> <b>Remarks</b></td></tr>";
for($i=0;$i<$num;$i++)
{
$row=mysql_fetch_row($fetch);
echo "<tr>";
echo"<td>$row[0]</td>";
echo"<td>$row[1]</td>";
echo"<td>$row[2]</td>";
echo"<td>$row[3]</td>";
echo"<td>$row[4]</td>";
echo"<td>$row[5]</td>";
echo"<td>$row[6]</td>";
echo"<td>$row[7]</td>";
echo"<td>$row[8]</td>";
echo"</tr>";
}//for
echo"</table>";
}
//now this is the link..
echo '<a href="'.$_SERVER['PHP_SELF'].'?startrow='.($startrow+10).'"><img align=left height=50px width=50px src="next.png"/></a>';
$prev = $startrow - 10;
//only print a "Previous" link if a "Next" was clicked
if ($prev >= 0)
echo '<a href="'.$_SERVER['PHP_SELF'].'?startrow='.$prev.'"><img align=right height=50px width=50px src="previous.png"/></a>';
?>
我的問題是當用戶提交數據到MySQL數據庫,然後在瀏覽器中首先顯示該細節。
謝謝。
最近的條目不是最先顯示的嗎? – ethrbunny
@ethrbunny,這正是他想要的...... – ElmoVanKielmo
@ user2520162,不要在新代碼中使用'mysql _...'函數 - 使用'mysqli _...'http://php.net/manual/en /book.mysqli.php – ElmoVanKielmo