晚上好/早上好,
我有一个分页的表格。第一页出现在primarycontent div中,这是我想要它的地方..但是当点击第2,3页时,它会打开另一个链接,我希望它在主内容div中打开,就像第一页,但无法弄清楚如何去做。同样,当点击上一个按钮时,它将转到第1页,而不是第50页上当前页面前的页面,转到第1页。这是我的代码。
require_once ('mysqli_connect.php');
$display = 30;
if (isset($_GET['p']) && is_numeric ($_GET['p']))
{
$pages = $_GET['p'];
} else {
$q = "SELECT COUNT(NewCustomerID) FROM customer";
$r = @mysqli_query($dbc, $q);
$row = @mysqli_fetch_array ($r, MYSQLI_NUM);
$records = $row[0];
if ($records > $display){//more than 1 page.
$pages = ceil($records/$display);
} else {
$pages = 1;
}
} // end of p IF
if (isset($_GET['s']) && is_numeric ($_GET['s']))
{
$start = $_GET['s'];
} else {
$start = 0;
}
$q = "SELECT(NewCustomerID) AS customerid,
(OldCustomerID) AS oldcustomerid,
(FirstName) AS FirstName,
(MiddleName) AS MiddleName,
(LastName) AS LastName,
(UserName) AS UserName,
(CarID) AS CarID,
(CarColorID) AS CarColorID,
(ComputerID) AS ComputerID,
(IsLaptop) AS LaptopID,
(RaceID) AS RaceID,
(ResidenceID) AS ResidenceID,
(BirthMonthID) AS BirthMonthID
FROM customer ORDER BY LastName ASC LIMIT $start, $display";
$r = @mysqli_query($dbc, $q); if(!$r){die(mysqli_error($dbc));}
Echo '
NewCustomerID | OldCustomerID | FirstName | MiddleName | LastName | UserName | CarID | CarColorID | ComputerID | IsLaptop | RaceID | ResidenceID | BirthMonthID |
$bg = '#eeeeee'; // set initial back ground color
while ($row = mysqli_fetch_array($r, MYSQLI_ASSOC)) {
$bg = ($bg =='#eeeeee' ? '#ffffff' : '#eeeeee'); // switch the background color.
echo '
' . $row['customerid'] . '' . $row['oldcustomerid']. '' . $row['FirstName']. '' . $row['MiddleName']. '' . $row['LastName']. '' . $row['UserName'].'' . $row['CarID'].'' . $row['CarColorID'].'' . $row['BirthMonthID'].'' . $row['ComputerID'].'' . $row['LaptopID'].'' . $row['RaceID'].'' . $row['ResidenceID'].'';} // end of while loop
echo '
';mysqli_free_result($r);
mysqli_close($dbc);
// make the links to the other pages if necessary
if ($pages >1) {
// add some spaces and start a paragraph
echo '
';
// determine what page the script is on:
$current_page = ($start/$display)+1;
// if it's not the first page, make a previous link;
if ($current_page !=1) {
echo 'Previous ';
}
for ($i = 1; $i <= $pages; $i++) {
if ($i != $current_page) {
echo ''
. $i . ' ';
}else{
echo $i . ' ';
}
}// end of FOR loop
// if it is not the last page, make a next button
if ($current_page != $pages) {
echo 'Next';
}
echo '
'; // close the paragraph} // endo of links section
?>