Help with Pagination...
Posted: Tue Jan 24, 2006 5:25 pm
Hi, i have this problem, the pagination works great, but what i want it to do is to put a <br> tag (hope you understnad me), after 10 pages, for example.
1 2 3 4 5 6 7 8 9 10
11 12 13 14 15 16 17....
I have it like this :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 ...
and its causing the site to look odd... (http://www.planetbabes.net - Adult content)
here's the code
1 2 3 4 5 6 7 8 9 10
11 12 13 14 15 16 17....
I have it like this :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 ...
and its causing the site to look odd... (http://www.planetbabes.net - Adult content)
here's the code
Code: Select all
//**********beginning of pagination************
$page = $_GET['page'];
//********check and see what page we're on*********
if(empty($page)){ // Checks if the $page variable is empty (not set)
$page = 1; // If it is empty, we're on page 1
}
$limitvalue = $page * $limit - ($limit);
// Ex: (2 * 25) - 25 = 25 <- data starts at 25
$query = "SELECT * FROM galeria ORDER BY ID_Prueba DESC LIMIT $limitvalue, $limit";
$result = mysql_query($query) or die("Error: " . mysql_error());
// Selects all the data from table.
// mysql_error() will print an error if one occurs.
/* Tip: The MySQL LIMIT value syntax is as follows:
LIMIT $row_to_start_at, $how_many_rows_to_return
*/
//***create a table to display data*****
$bgcolor = "#FFFFFF";
/* Sets up one of the background colors. The color stated here will be
displayed second */
echo("<table width=350>");
// Just a simple table
while($row = mysql_fetch_array($result)){
/* This starts the loop (a while loop). What this does is returns a row of data
to the $row array. Each time the loop restarts, the next row of data is used.
So, each pass of the loop returns a different row of data. */
// Start The Background Check
if ($bgcolor == "#FFFFFF"){
$bgcolor = "#FFFFFF";
}else{
$bgcolor = "#FFFFFF";
}
/* Tip: The color you want to appear first on the list should be where the
#FFFFFF is listed. What this script does is checks to see if #E0E0E0 was used
last; if it was, then it'll use #FFFFFF. All you have to do is replace the
colors of your choice. */
echo("<tr bgcolor=333333><td><center><b><font color=white size=2 face=verdana>");
// Here we start table row & table data
// Make sure your bgcolor is the $bgcolor variable
echo($row["Nombre"]);
//Here we have the name of the recipe field
echo("</b></center></font></td></tr><tr><td><center><img src=");
// Here we end the one section of table data, and start another.
echo($row["Imagen"]);
// Prints the author id field
echo("></center></td></tr><tr><td><center><a target=_blank href=out.php?dire=");
// Here we end the one section of table data, and start another.
echo($row["Url"]);
// Here we make the link to the full description of the recipe.
echo("><img src=../common/view_gallery.gif border=0></a></center></td></tr>");
// Here we end the table data & table row
} /* This closes the loop. Anything after this bracket will display after the
data you've pulled from the database. */
echo("</table>");
/* While we're at it, let's close the table tag--we don't want other data
inside this table */
//****make the previous button********
if ($page != 1){
$pageprev = $page-1;
echo("<a href=\"{$_SERVER['PHP_SELF']}?page=$pageprev\"><font size=2 face=verdana><b>PREVIOUS</b></font>"."</a> ");
}else{
echo("<font size=2 face=verdana><b>PREVIOUS </b></font>");
}
//*****list the page numbers in link format********
$numofpages = $totalrows / $limit;
for ($i = 1; $i <= $numofpages; $i++){
if ($i == $page){
echo($i." ");
}else{
echo("<b><font size=2 face=verdana><b><a href=\"{$_SERVER['PHP_SELF']}?page=$i\">$i</a> </b>");
}
}
//*****check for remaing rows******
if (($totalrows % $limit) != 0){
if ($i == $page){
echo($i." ");
}else{
echo("<a href=\"{$_SERVER['PHP_SELF']}?page=$i\">$i</a> </font>");
}
}
//****make the next button*****
if (($totalrows - ($limit * $page)) > 0){
$pagenext = $page+1;
echo("<a href=\"{$_SERVER['PHP_SELF']}?page=$pagenext\">NEXT"."</a>");
}else{
echo("<font size=2 face=verdana><b> NEXT</b></font>");
}
mysql_free_result($result);
?>