ok i read a tutorial on Pagination in PHP and i got this this but it still displays all of the mysql query
i dont know if i got it dont right cuz it diden tell u much ? can any one help me out.
i wants to load the mysql data that are links and list only 15 prepage and then.
pagination. just a note it show the data but it dont pagination it.
<link rel="stylesheet" href="1.css" type="text/css" />
<?
include("../config_conn.php");
include("../loaded.php");
?>
<?php
if(!empty($_GET["start"])){
$start = $_GET['start'];// To take care global variable if OFF
}else{
$start = 0;
}
if(!($start > 0)) { // This variable is set to zero for the first page
$start = 0;
}
$eu = ($start - 0);
$limit = 15; // No of records to be shown per page.
$whathis = $eu + $limit;
$back = $eu - $limit;
$next = $eu + $limit;
// to check the total number of records
$query = mysql_query(" SELECT * FROM links ") or die (mysql_error());
$total_rows = mysql_num_rows($query);
while($linelink2=mysql_fetch_array($resultlink2)) {
echo "<table align=center width=550>"; echo "<tr>
<td>$linelink2[linktitle]</td>
<td><a class=\"link1\" href=\"<?=\$linelink2[linkurl]?>\" target=\"_blank\"><?=\$linelink2[linkurl]?></a></td>
</tr> ";
echo "</table>";
}
//select the record with limitation SELECT * FROM `links` WHERE linkid ORDER BY RAND() LIMIT 15
$query = mysql_query(" SELECT * FROM `links` limit $eu, $limit") or die (mysql_error());
echo "<table align=center width=550>";
//code for previous
if($back >=0) {
echo "<a class=\"pagination\" href='test.php?start=$back'><font face='Verdana' size='2'>PREV</font></a> ";
}
//code for the number of page with links
$i = 0;
$x = 1;
for($i=0;$i < $total_rows;$i=$i+$limit){
if($i != $eu){
echo "<a class=\"pagination\" href='test.php?start=$i'><font face='Verdana' size='2'>$x</font></a> ";
}else {
echo "<font face='Verdana' size='4' color=red>$x</font>";
} // Current page is not displayed as link and given font color red
$x = $x+1;
}
//code for next
if($whathis < $total_rows) {
echo "<a class=\"pagination\" href='test.php?start=$next'><font face='Verdana' size='2'>NEXT</font></a>";
}
?>