PHP分页代码第二页怎么显示,在php中的主要内容div中的分页表中显示第二页

晚上好/早上好,

我有一个分页的表格。第一页出现在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

?>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值