1 回答
TA貢獻1811條經(jīng)驗 獲得超5個贊
計算項目將顯示的頁面并在更新后重定向到該頁面:
您已經(jīng)從 獲得了 id $ID=$_POST['id'];,讓我們找到它的位置:
// Execute query, searching for id less or equal than the ID you've got previously
$result = mysqli_query($con,"SELECT COUNT(*) FROM `b_2011` WHERE id <= $ID");
// This query will return just 1 row with 1 value
$row = mysqli_fetch_row($result);
// First item holds the counter
$records = $row[0];
// Get page number to go
$page = ($records == 0) ? 1 : ceil($records / $total_records_per_page);
// Redirect to the page
header("Location: index.php?page_no=$page");
// End the script
exit;
順便說一下,你的腳本有被攻擊的風(fēng)險,請考慮使用準備好的語句,你可以從我如何防止用 PHP 進行 SQL 注入?
- 1 回答
- 0 關(guān)注
- 167 瀏覽
添加回答
舉報
