Pagination Help!!

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
kanchan
Forum Commoner
Posts: 80
Joined: Tue Nov 30, 2004 12:03 pm

Pagination Help!!

Post by kanchan »

I have a pagination script here:

Code: Select all

<?
 
$total_results = mysql_result(mysql_query("SELECT COUNT(*) as Num FROM wallpapers"),0); 
 
$total_pages = ceil($total_results / $max_wp_results); 
 
echo "<b><strong>";
echo "<center>Pages</br>"; 
 
// Build Previous Link 
if($page > 1){ 
    $prev = ($page - 1); 
    echo "<a href=\"".$_SERVER['PHP_SELF']."?page=$prev\";><font color=\"#6699CC\">Previous&nbsp</font></a>"; 
} 
 
for($i = 1; $i <= $total_pages; $i++){ 
    if(($page) == $i){ 
        echo "$i&nbsp;"; 
        } else { 
            echo "<a href=\"".$_SERVER['PHP_SELF']."?page=$i\";>$i</a>&nbsp;"; 
    } 
} 
 
// Build Next Link 
if($page < $total_pages){ 
    $next = ($page + 1); 
    echo "<a href=\"".$_SERVER['PHP_SELF']."?page=$next\";><font color=\"#6699CC\">Next</font></a>"; 
}
 
?>

Now what i want is

i want to put this codes into table like this :

Code: Select all

<table border="0" cellpadding="2" cellspacing="2">
    <tr>
      <td align="center" bgcolor="#000000" width="19"><font color="white"><b>1</b></font></td>
      <td width="19">2</td>
      <td width="19">3</td>
      <td width="19">4</td>
      <td width="19">5</td>
      <td>[next]</td>
    </tr>
</table>

how can i put those codes into the table above??
User avatar
jayshields
DevNet Resident
Posts: 1912
Joined: Mon Aug 22, 2005 12:11 pm
Location: Leeds/Manchester, England

Re: Pagination Help!!

Post by jayshields »

Change your existing echo calls and perhaps add some new ones?
kanchan
Forum Commoner
Posts: 80
Joined: Tue Nov 30, 2004 12:03 pm

Re: Pagination Help!!

Post by kanchan »

jayshields wrote:Change your existing echo calls and perhaps add some new ones?
what is that mean??
coz i m new to PHP so....
User avatar
Eran
DevNet Master
Posts: 3549
Joined: Fri Jan 18, 2008 12:36 am
Location: Israel, ME

Re: Pagination Help!!

Post by Eran »

basically, you would prefer to have someone write the code for you
Post Reply