0
我有三個獲取參數在PHP mysqli我必須先存儲數據,然後搜索數據,然後在列表視圖中顯示,但我想顯示列表視圖與分頁限制3 ....請幫助我,我是在PHP新...在三個參數在PHP中分頁獲取方法
register.php
<?php
include_once 'DB_Connect.php';
if (isset($_GET['finder'])) {
$name = $_GET['name'];
$ph = $_GET['phno'];
$date = date('Y-m-d');
mysqli_query($con, "INSERT INTO donee (name,ph_no,pincode,time,blood_gp,upload_time) VALUES ('$name','$ph','$pin','$time','$blgp','$date')");
if (!mysqli_error($con)) {
echo '<script>alert("Success...Registertion is Successfully.."); </script>';
} else {
echo '<script>alert("Error...Your Registration is not Successfully..");</script> ';
}
}
searchdata.php
<?php
$blgp = $_GET['blgp'];
$time = $_GET['timing'];
$pin = $_GET['pin'];
$result = mysqli_query($con, "SELECT * FROM doner WHERE pincode='$pin' AND timing='$time' AND blood_gp='$blgp'");
$rows = mysqli_num_rows($result);
if ($rows > 0) {
while ($post = mysqli_fetch_assoc($result)) {
echo $post['doner_id'];
echo $post["file"];
echo $post["name"];
echo $post["ph_no"];
echo $post["blood_gp"];
}
} else {
<h3>No Donors are Available</h3>;
}
?>
添加兩個新的參數$ _GET [ '抵消']和$ _GET [ '限制' 在searchdata.php 比限制查詢搜索 http://www.w3schools.com/php/php_mysql_select_limit。 asp –
並清理您的輸入...您的代碼依然容易受到SQL注入的影響。 – mituw16
@KapitulaAlexey:不要鏈接到w3fools。他們的代碼是垃圾並且充滿了糟糕/可怕的編碼習慣。鏈接到實際的PHP或MySQL官方文檔。或更好,但在這個網站上的另一個答案。這基本上是「如何分頁」的一個騙局,並且網站上有很多示例。 –