我正在尝试使用PHP创建一个小型Web应用程序,我终于设法让脚本获取数据库中表中的第一行,然后选择下一行和上一行,使得能够循环遍历所有在表单中显示每一行时的记录。
在我的一个页面上,我需要从表(A)中的行(由名为' caleadID'的字段标识)中收集数据,然后插入另一个表(B)。我已设法获取此数据并插入表(B)。将数据插入表(B)后,它将我重定向到另一个页面并显示我刚刚插入表单中的数据,我在此页面上有一个下一个和上一个按钮循环遍历表(B)的行类似到另一页。下一个和上一个按钮不能正常工作。
任何帮助都将受到赞赏!
$page = intval($_GET['page']);
$limitStart = $page - 1;
if($limitStart < 0) {
$limitStart = 0;
}
if(isset($_GET['caleadID'])) {
$caleadID = $_GET['caleadID'];
$query = "SELECT caleadID, region, siteaddr1, siteaddr2, siteaddr3, siteaddr4, sitepcode, ";
$query .= "addgennotes, description, value, award, awardaddr1, awardaddr2, awardaddr3, awardaddr4, awardpcode, ";
$query .= "phone_number, fax_number, fldAwardedWebsite, fldAwardedEmail, contact_name, date FROM tblLeads_Awarded WHERE ";
$query .= "caleadID = '" . $caleadID . "'";
$query .= " LIMIT " . $limitStart . ',3';
$result = mysqli_query($connection, $query);
confirm_query($result);
}
else
{
$query = "SELECT caleadID, region, siteaddr1, siteaddr2, siteaddr3, siteaddr4, sitepcode, ";
$query .= "addgennotes, description, value, award, awardaddr1, awardaddr2, awardaddr3, awardaddr4, awardpcode, ";
$query .= "phone_number, fax_number, fldAwardedWebsite, fldAwardedEmail, contact_name, date FROM tblLeads_Awarded WHERE 1";
$query .= " LIMIT " . $limitStart . ',3';
$result = mysqli_query($connection, $query);
confirm_query($result);
}
$result_array = array();
while($row = mysqli_fetch_assoc($result)) {
$result_array[] = $row;
}
if(intval($page) === 0) {
$previousRecord = NULL;
$currentRecord = $result_array[0];
$nextRecord = $result_array[1];
}
else
{
$previousRecord = $result_array[0];
$currentRecord = $result_array[1];
$nextRecord = $result_array[2];
}
if($previousRecord) {
$prevPage = $page - 1;
if($prevPage < 0) {
$pagePage = 0;
}
$prevLink = 'view_leads.php?page=' . $prevPage;
}
if($nextRecord) {
$nextLink = 'view_leads.php?page=' . ($page + 1);
}
?>
<div id="tradesmen_data_navigation">
<a href="<?PHP echo $prevLink ?>"><input type="submit" name="previous" value="Previous Record" /></a>
<a href="<?PHP echo $nextLink ?>"><input type="submit" name="next" value="Next Record" /></a>
</div>