Guys, look at my little brother, why isn't my page handy?

Source: Internet
Author: User
Let's see why my pagination isn't good.
$sql _azsqd= "SELECT * from S_qzjx_azsqd where ejdwbm= ' $coid ' and substr (sblbdm,1,2) = ' $id ' ORDER by sqdbh Desc ';
if ($page = = "") {$page = 0;}
$count = 10; I'm going to write a total of 10 records.
$i = $count-1;
$msgnum = 2;
$start = $page * $MSGNUM;
$end = $start + $msgnum;
if ($end > $i) $end = $i;
$totalpage = $i/$msgnum;
if ($page > $totalpage) {$page = $totalpage;}
if ($totalpage > Round ($totalpage)) {$totalpage =round ($totalpage) +1;}
else{$totalpage =round ($totalpage);}
if ($page > 0) {$row = $page * $msgnum + 1;}
if ($row = = "") {$row = 1;}
?>

for ($i = $start; $i < $end; $i + +)
{
Here is the Read record
}

$pagestr = "";
if ($page > 0) $pagestr = $pagestr. "On the page-";
$pagestr = $pagestr. "[subsection";
for ($i =0; $i < $totalpage; $i + +) {
if ($i! = $page) {
$pagestr = $pagestr. " ". ($i + 1). " ";
} else{
$pagestr = $pagestr. " ". ($i + 1). " ";
}
}
$pagestr = $pagestr. "Page]";
if ($page < ($totalpage-1)) $pagestr = $pagestr. "-Next page";
echo "Total". $totalpage. "Page". $pagestr;

Now my pagination is all right, just read all the data on the first page, how can I segment the data? I can not use limit, because it is for Oracle operation, I just want to use this for ($i = $start; $i < $end; $i + +) loop to segment the data, thank you, who can help?

------Solution--------------------
It's very convenient to use ADODB.
------Solution--------------------
SELECT * FROM (select RowNum rm,s_qzjx_azsqd.* from S_QZJX_AZSQD) where s_qzjx_azsqd.ejdwbm= ' $coid ' and s_qzjx_azsqd.sub STR (sblbdm,1,2) = ' $id ' and rm> =1 and RM <=10 1 to 10 rows in Oracle----
------Solution--------------------
Don't use anything that's not universal!

If you are MySQL, use the legendary top paging feature--limit!!

If the MSSQL is alive with other databases, please use the Mosaic SELECT statement to page out! Make sure you use the cool!

Hey, the specific method is not to publish, is not published ~ And so I finished writing functions, a piece of post it
------Solution--------------------
"The first page reads out all the data." If you save an array, you're going to end up with a subscript.
------Solution--------------------
$totalpage = $i/$msgnum;
if ($page > $totalpage) {$page = $totalpage;}
if ($totalpage > Round ($totalpage)) {$totalpage =round ($totalpage) +1;}
else{$totalpage =round ($totalpage);}

\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

There's also a problem here $page will appear decimals, I will write:

$totalpage =ceil ($i/$msgnum);
if ($page > $totalpage) {$page = $totalpage;}

==================================
  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.