0

我想用下一个和上一个按钮导航记录,但是我遇到了以下错误

“您的 SQL 语法有错误;请查看与您的 MySQL 服务器版本相对应的手册,以在第 1 行的 'ORDER BY Sr_no DESC LIMIT 1' 附近使用正确的语法”请帮助我解决此错误

我的代码是

<?php
$id = $_GET['Sr_no'];
$id = $currentid;
$prevquery = "SELECT Sr_no, Entry_Date, Agent_Name, Process_Name, Donar_Name,Company_Name,Designation, Add1, Add2, Add3, Pincode, City, Contact_no,Mobile_no,Nearest_station,Suburbans, Pickup_time,Pickup_Date, Confirmation_Status,Last_Yr_Contribution,Pickup_Amount,Final_Donate_amt,Final_Status,DOB,Email_Id,Chq_Deposite_Date,Form_No,Cheque_Date,Cheque_No,Bank_Name,Chq_Amount,Pan_No,MICR_No,CLR_Loc,Batch_File,Donar_Code FROM leads WHERE Sr_no < $currentid ORDER BY Sr_no DESC LIMIT 1";
$prevresult = mysql_query($prevquery) or die(mysql_error());
while ($prevrow = mysql_fetch_array($prevresult)) {
    $previd = $prevrow['Sr_no'];
}
$nextquery = "SELECT Sr_no, Entry_Date, Agent_Name, Process_Name, Donar_Name,Company_Name,Designation, Add1, Add2, Add3, Pincode, City, Contact_no, Mobile_no,Nearest_station,Suburbans, Pickup_time, Pickup_Date, Confirmation_Status, Last_Yr_Contribution, Pickup_Amount,Final_Donate_amt,Final_Status,DOB,Email_Id,Chq_Deposite_Date,Form_No,Cheque_Date,Cheque_No,Bank_Name,Chq_Amount,Pan_No,MICR_No,CLR_Loc,Batch_File,Donar_Code FROM  leads WHERE Sr_no < $currentid ORDER BY Sr_no DESC LIMIT 1";
$nextresult = mysql_query($nextquery) or die(mysql_error());
while ($nextrow = mysql_fetch_array($nextresult)) {
    $nextid = $nextrow['Sr_no'];
}
?>

<a href="edit1.php?Sr_no=<?php echo $previd; ?>">Previous</a>
<a href="edit1.php?Sr_no<?php echo $nextid; ?>">Next</a>
4

1 回答 1

1

我认为你的代码是

$id=$_GET['Sr_no'];
$currentid = $id;

而不是这个

$id=$_GET['Sr_no'];
$id = $currentid;
于 2013-09-03T09:05:32.587 回答