line no 03 set the number of result rows. ex-number of product in the page
line no 04 and 05 set the start result row and end row.
0)
{
$eu=$start;
}
else
{
$eu =0;
}
?>
{
$eu=$start;
}
else
{
$eu =0;
}
?>
The query will retrieve the specific portion of data that limit by the start and end values.
$query=" SELECT * FROM student_adv limit $eu,$page_end";
$result=mysql_query($query);
echo mysql_error();
while($noticia = mysql_fetch_array($result))
{
if($bgcolor=='#f1f1f1'){$bgcolor='#ffffff';}
else{$bgcolor='#f1f1f1';}
echo "";
echo " $noticia[id]";
echo " $noticia[name]";
echo " $noticia[class]";
echo " $noticia[mark]";
echo "";
}
Retrieve all the data and count the number of rows in the result.line no 06 count the number of pages.line no 12 print the page numbers and pass the start and end row for the next page.
$query2=" SELECT * FROM student_adv ";
$result2=mysql_query($query2);
echo mysql_error();
$nume=mysql_num_rows($result2);
//setting pages
$pages_count=$nume/$limit;
print "";
for($i=0;$i<$pages_count;$i++) { $limitp=$limit; $end_limit=$i*$limit; print " ".$i.""; }
I will appreciate your comments.Let me know any errors or improvements.
No comments:
Post a Comment