The biggest problem we encountered in the design of the message board was how to make the message board have a page turning function and automatically determine whether it has reached the last page. Below I will share with you the technology I used when designing the message board. :
First connect to the database, which I won’t go into here. Each statement will be explained in detail below.
.
. .
. result);#Calculate how many messages there are in total
for ($i=0; $i<$total; $i++) #Assign the content of each message to a function
{
$show[ $i]=mysql_result($result,$i,"Message content");#In this way, the first message is in $show[0], and the second message is in $show[1]...
}
if(!$page){$page=0;} #Assign a value to the page number. If it has already been assigned, it will not move. This is the only way to call this page again.
$eachpage=any Number; #The number of messages you want to display on no page
$start=$page*$eachpage;#Here is the number of rows in the database of the first statement displayed on each page. For example, if the user turns to the second page, then The number of rows in the database of the first statement to change the page is $page*$eachpage, that is, "1*the number of messages displayed on each page"
$end=$start+$eachpage;#This is the last line of the page change Number of rows in the database
if($end>$total) {$end=$total;}#If you turn to the last page, the last row is often not "$start+$eachpage", but the number in the database The last line
$totalpage=ceil($total/$eachpage);#This is a statement to calculate the number of pages. ceil() is the rounding function
?>
. .
.
. The last line of the page
echo '
www.bkjia.com