pagination problem

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • dannysheps@hotmail.com
    Second Lieutenant

    • Feb 2008
    • 138

    pagination problem

    Hello
    i have this code down , and it show's the first page ok but after i click next it doesnt show anything , any help ?

    the site its running on now is : www.brasilwebdesign.com/menu
    *only the category search is avaliable now for this code and chose "restaurants" only

    thanks

    Code:
    [COLOR=#000000][COLOR=#000000][COLOR=#0000BB]<?php 
    
    $name[/COLOR][COLOR=#007700]=[/COLOR][COLOR=#0000BB]$_GET[/COLOR][COLOR=#007700][[/COLOR][COLOR=#DD0000]'name'[/COLOR][COLOR=#007700]];
    [/COLOR][COLOR=#0000BB]$category[/COLOR][COLOR=#007700]=[/COLOR][COLOR=#0000BB]$_GET[/COLOR][COLOR=#007700][[/COLOR][COLOR=#DD0000]'category'[/COLOR][COLOR=#007700]];
    [/COLOR][COLOR=#0000BB]$food_type[/COLOR][COLOR=#007700]=[/COLOR][COLOR=#0000BB]$_GET[/COLOR][COLOR=#007700][[/COLOR][COLOR=#DD0000]'food_type'[/COLOR][COLOR=#007700]];
    
    [/COLOR][COLOR=#FF8000]// Connects to your Database 
    [/COLOR][COLOR=#0000BB]mysql_connect[/COLOR][COLOR=#007700]([/COLOR][COLOR=#DD0000]"localhost"[/COLOR][COLOR=#007700], [/COLOR][COLOR=#DD0000]"*******"[/COLOR][COLOR=#007700], [/COLOR][COLOR=#DD0000]"*********"[/COLOR][COLOR=#007700]) or die([/COLOR][COLOR=#0000BB]mysql_error[/COLOR][COLOR=#007700]()); 
    [/COLOR][COLOR=#0000BB]mysql_select_db[/COLOR][COLOR=#007700]([/COLOR][COLOR=#DD0000]"***********"[/COLOR][COLOR=#007700]) or die([/COLOR][COLOR=#0000BB]mysql_error[/COLOR][COLOR=#007700]()); 
    
    
    [/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB]$tbl_name[/COLOR][COLOR=#007700]=[/COLOR][COLOR=#DD0000]"menu"[/COLOR][COLOR=#007700];[/COLOR][COLOR=#0000BB] [/COLOR][COLOR=#0000BB][/COLOR][COLOR=#FF8000]//your table name
    [/COLOR][COLOR=#0000BB][/COLOR][COLOR=#FF8000]// How many adjacent pages should be shown on each side?
    [/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB]$adjacents [/COLOR][COLOR=#007700]= [/COLOR][COLOR=#0000BB]3[/COLOR][COLOR=#007700];
    [/COLOR][COLOR=#0000BB]
    [/COLOR][COLOR=#0000BB][/COLOR][COLOR=#FF8000]/* 
       First get total number of rows in data table. 
       If you have a WHERE clause in your query, make sure you mirror it here.
    */
    [/COLOR][COLOR=#0000BB]
    [/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB]$query [/COLOR][COLOR=#007700]= [/COLOR][COLOR=#DD0000]"SELECT COUNT(*) as num FROM $tbl_name WHERE category='$category' "[/COLOR][COLOR=#007700]; 
    [/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB]$total_pages [/COLOR][COLOR=#007700]= [/COLOR][COLOR=#0000BB]mysql_fetch_array[/COLOR][COLOR=#007700]([/COLOR][COLOR=#0000BB]mysql_query[/COLOR][COLOR=#007700]([/COLOR][COLOR=#0000BB]$query[/COLOR][COLOR=#007700]));
    [/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB]$total_pages [/COLOR][COLOR=#007700]= [/COLOR][COLOR=#0000BB]$total_pages[/COLOR][COLOR=#007700][[/COLOR][COLOR=#0000BB]num[/COLOR][COLOR=#007700]];
    [/COLOR][COLOR=#0000BB]
    [/COLOR][COLOR=#0000BB][/COLOR][COLOR=#FF8000]/* Setup vars for query. */
    [/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB]$targetpage [/COLOR][COLOR=#007700]= [/COLOR][COLOR=#DD0000]"results.php"[/COLOR][COLOR=#007700]; [/COLOR][COLOR=#0000BB] [/COLOR][COLOR=#FF8000]//your file name  (the name of this file)
    [/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB]$limit [/COLOR][COLOR=#007700]= [/COLOR][COLOR=#0000BB]3[/COLOR][COLOR=#007700]; [/COLOR][COLOR=#0000BB] [/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#FF8000]//how many items to show per page
    [/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB]$page [/COLOR][COLOR=#007700]=[/COLOR][COLOR=#0000BB]$_GET[/COLOR][COLOR=#007700][[/COLOR][COLOR=#DD0000]'page'[/COLOR][COLOR=#007700]];
    [/COLOR][COLOR=#0000BB]if([/COLOR][COLOR=#0000BB]$page[/COLOR][COLOR=#007700]) 
    [/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB]$start [/COLOR][COLOR=#007700]= ([/COLOR][COLOR=#0000BB]$page [/COLOR][COLOR=#007700]- [/COLOR][COLOR=#0000BB]1[/COLOR][COLOR=#007700]) * [/COLOR][COLOR=#0000BB]$limit[/COLOR][COLOR=#007700]; [/COLOR][COLOR=#0000BB] [/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#FF8000]//first item to display on this page
    [/COLOR][COLOR=#0000BB]else
    [/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB]$start [/COLOR][COLOR=#007700]= [/COLOR][COLOR=#0000BB]0[/COLOR][COLOR=#007700];[/COLOR][COLOR=#0000BB] [/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#FF8000]//if no page var is given, set start to 0
    [/COLOR][COLOR=#0000BB]
    [/COLOR][COLOR=#0000BB]
    [/COLOR][COLOR=#0000BB][/COLOR][COLOR=#FF8000]/* Get data. */
    [/COLOR][COLOR=#0000BB]
    [/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB]$sql [/COLOR][COLOR=#007700]= [/COLOR][COLOR=#DD0000]"SELECT * FROM $tbl_name WHERE category='$category' LIMIT $start, $limit"[/COLOR][COLOR=#007700];
    [/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB]$result [/COLOR][COLOR=#007700]= [/COLOR][COLOR=#0000BB]mysql_query[/COLOR][COLOR=#007700]([/COLOR][COLOR=#0000BB]$sql[/COLOR][COLOR=#007700]);
    [/COLOR][COLOR=#0000BB]
    [/COLOR][COLOR=#0000BB][/COLOR][COLOR=#FF8000]/* Setup page vars for display. */
    [/COLOR][COLOR=#0000BB]if ([/COLOR][COLOR=#0000BB]$page [/COLOR][COLOR=#007700]== [/COLOR][COLOR=#0000BB]0[/COLOR][COLOR=#007700]) [/COLOR][COLOR=#0000BB]$page [/COLOR][COLOR=#007700]= [/COLOR][COLOR=#0000BB]1[/COLOR][COLOR=#007700];[/COLOR][COLOR=#0000BB] [/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#FF8000]//if no page var is given, default to 1.
    [/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB]$prev [/COLOR][COLOR=#007700]= [/COLOR][COLOR=#0000BB]$page [/COLOR][COLOR=#007700]- [/COLOR][COLOR=#0000BB]1[/COLOR][COLOR=#007700];[/COLOR][COLOR=#0000BB] [/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#FF8000]//previous page is page - 1
    [/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB]$next [/COLOR][COLOR=#007700]= [/COLOR][COLOR=#0000BB]$page [/COLOR][COLOR=#007700]+ [/COLOR][COLOR=#0000BB]1[/COLOR][COLOR=#007700];[/COLOR][COLOR=#0000BB] [/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#FF8000]//next page is page + 1
    [/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB]$lastpage [/COLOR][COLOR=#007700]= [/COLOR][COLOR=#0000BB]ceil[/COLOR][COLOR=#007700]([/COLOR][COLOR=#0000BB]$total_pages[/COLOR][COLOR=#007700]/[/COLOR][COLOR=#0000BB]$limit[/COLOR][COLOR=#007700]);[/COLOR][COLOR=#0000BB] [/COLOR][COLOR=#0000BB][/COLOR][COLOR=#FF8000]//lastpage is = total pages / items per page, rounded up.
    [/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB]$lpm1 [/COLOR][COLOR=#007700]= [/COLOR][COLOR=#0000BB]$lastpage [/COLOR][COLOR=#007700]- [/COLOR][COLOR=#0000BB]1[/COLOR][COLOR=#007700];[/COLOR][COLOR=#0000BB] [/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#FF8000]//last page minus 1
    [/COLOR][COLOR=#0000BB]
    [/COLOR][COLOR=#0000BB][/COLOR][COLOR=#FF8000]/* 
    Now we apply our rules and draw the pagination object. 
    We're actually saving the code to a variable in case we want to draw it more than once.
    */
    [/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB]$pagination [/COLOR][COLOR=#007700]= [/COLOR][COLOR=#DD0000]""[/COLOR][COLOR=#007700];
    [/COLOR][COLOR=#0000BB]if([/COLOR][COLOR=#0000BB]$lastpage [/COLOR][COLOR=#007700]> [/COLOR][COLOR=#0000BB]1[/COLOR][COLOR=#007700])
    [/COLOR][COLOR=#0000BB]{[/COLOR][COLOR=#0000BB] 
    [/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB]$pagination [/COLOR][COLOR=#007700].= [/COLOR][COLOR=#DD0000]"<div class=\"pagination\">"[/COLOR][COLOR=#007700];
    [/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#FF8000]//previous button
    [/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB]if ([/COLOR][COLOR=#0000BB]$page [/COLOR][COLOR=#007700]> [/COLOR][COLOR=#0000BB]1[/COLOR][COLOR=#007700]) 
    [/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB]$pagination[/COLOR][COLOR=#007700].= [/COLOR][COLOR=#DD0000]"<a href=\"$targetpage?page=$prev\">« previous</a>"[/COLOR][COLOR=#007700];
    [/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB]else
    [/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB]$pagination[/COLOR][COLOR=#007700].= [/COLOR][COLOR=#DD0000]"<span class=\"disabled\">« previous</span>"[/COLOR][COLOR=#007700];[/COLOR][COLOR=#0000BB] 
    [/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB]
    [/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#FF8000]//pages 
    [/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB]if ([/COLOR][COLOR=#0000BB]$lastpage [/COLOR][COLOR=#007700]< [/COLOR][COLOR=#0000BB]7 [/COLOR][COLOR=#007700]+ ([/COLOR][COLOR=#0000BB]$adjacents [/COLOR][COLOR=#007700]* [/COLOR][COLOR=#0000BB]2[/COLOR][COLOR=#007700]))[/COLOR][COLOR=#0000BB] [/COLOR][COLOR=#FF8000]//not enough pages to bother breaking it up
    [/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB]{[/COLOR][COLOR=#0000BB] 
    [/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB]for ([/COLOR][COLOR=#0000BB]$counter [/COLOR][COLOR=#007700]= [/COLOR][COLOR=#0000BB]1[/COLOR][COLOR=#007700]; [/COLOR][COLOR=#0000BB]$counter [/COLOR][COLOR=#007700]<= [/COLOR][COLOR=#0000BB]$lastpage[/COLOR][COLOR=#007700]; [/COLOR][COLOR=#0000BB]$counter[/COLOR][COLOR=#007700]++)
    [/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB]{
    [/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB]if ([/COLOR][COLOR=#0000BB]$counter [/COLOR][COLOR=#007700]== [/COLOR][COLOR=#0000BB]$page[/COLOR][COLOR=#007700])
    [/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB]$pagination[/COLOR][COLOR=#007700].= [/COLOR][COLOR=#DD0000]"<span class=\"current\">$counter</span>"[/COLOR][COLOR=#007700];
    [/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB]else
    [/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB]$pagination[/COLOR][COLOR=#007700].= [/COLOR][COLOR=#DD0000]"<a href=\"$targetpage?page=$counter\">$counter</a>"[/COLOR][COLOR=#007700];[/COLOR][COLOR=#0000BB] [/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB]
    [/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB]}
    [/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB]}
    [/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB]elseif([/COLOR][COLOR=#0000BB]$lastpage [/COLOR][COLOR=#007700]> [/COLOR][COLOR=#0000BB]5 [/COLOR][COLOR=#007700]+ ([/COLOR][COLOR=#0000BB]$adjacents [/COLOR][COLOR=#007700]* [/COLOR][COLOR=#0000BB]2[/COLOR][COLOR=#007700]))[/COLOR][COLOR=#0000BB] [/COLOR][COLOR=#FF8000]//enough pages to hide some
    [/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB]{
    [/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#FF8000]//close to beginning; only hide later pages
    [/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB]if([/COLOR][COLOR=#0000BB]$page [/COLOR][COLOR=#007700]< [/COLOR][COLOR=#0000BB]1 [/COLOR][COLOR=#007700]+ ([/COLOR][COLOR=#0000BB]$adjacents [/COLOR][COLOR=#007700]* [/COLOR][COLOR=#0000BB]2[/COLOR][COLOR=#007700]))[/COLOR][COLOR=#0000BB] [/COLOR][COLOR=#0000BB]
    [/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB]{
    [/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB]for ([/COLOR][COLOR=#0000BB]$counter [/COLOR][COLOR=#007700]= [/COLOR][COLOR=#0000BB]1[/COLOR][COLOR=#007700]; [/COLOR][COLOR=#0000BB]$counter [/COLOR][COLOR=#007700]< [/COLOR][COLOR=#0000BB]4 [/COLOR][COLOR=#007700]+ ([/COLOR][COLOR=#0000BB]$adjacents [/COLOR][COLOR=#007700]* [/COLOR][COLOR=#0000BB]2[/COLOR][COLOR=#007700]); [/COLOR][COLOR=#0000BB]$counter[/COLOR][COLOR=#007700]++)
    [/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB]{
    [/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB]if ([/COLOR][COLOR=#0000BB]$counter [/COLOR][COLOR=#007700]== [/COLOR][COLOR=#0000BB]$page[/COLOR][COLOR=#007700])
    [/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB]$pagination[/COLOR][COLOR=#007700].= [/COLOR][COLOR=#DD0000]"<span class=\"current\">$counter</span>"[/COLOR][COLOR=#007700];
    [/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB]else
    [/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB]$pagination[/COLOR][COLOR=#007700].= [/COLOR][COLOR=#DD0000]"<a href=\"$targetpage?page=$counter\">$counter</a>"[/COLOR][COLOR=#007700];[/COLOR][COLOR=#0000BB] [/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB]
    [/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB]}
    [/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB]$pagination[/COLOR][COLOR=#007700].= [/COLOR][COLOR=#DD0000]"..."[/COLOR][COLOR=#007700];
    [/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB]$pagination[/COLOR][COLOR=#007700].= [/COLOR][COLOR=#DD0000]"<a href=\"$targetpage?page=$lpm1\">$lpm1</a>"[/COLOR][COLOR=#007700];
    [/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB]$pagination[/COLOR][COLOR=#007700].= [/COLOR][COLOR=#DD0000]"<a href=\"$targetpage?page=$lastpage\">$lastpage</a>"[/COLOR][COLOR=#007700];[/COLOR][COLOR=#0000BB] [/COLOR][COLOR=#0000BB]
    [/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB]}
    [/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#FF8000]//in middle; hide some front and some back
    [/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB]elseif([/COLOR][COLOR=#0000BB]$lastpage [/COLOR][COLOR=#007700]- ([/COLOR][COLOR=#0000BB]$adjacents [/COLOR][COLOR=#007700]* [/COLOR][COLOR=#0000BB]2[/COLOR][COLOR=#007700]) > [/COLOR][COLOR=#0000BB]$page [/COLOR][COLOR=#007700]&& [/COLOR][COLOR=#0000BB]$page [/COLOR][COLOR=#007700]> ([/COLOR][COLOR=#0000BB]$adjacents [/COLOR][COLOR=#007700]* [/COLOR][COLOR=#0000BB]2[/COLOR][COLOR=#007700]))
    [/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB]{
    [/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB]$pagination[/COLOR][COLOR=#007700].= [/COLOR][COLOR=#DD0000]"<a href=\"$targetpage?page=1\">1</a>"[/COLOR][COLOR=#007700];
    [/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB]$pagination[/COLOR][COLOR=#007700].= [/COLOR][COLOR=#DD0000]"<a href=\"$targetpage?page=2\">2</a>"[/COLOR][COLOR=#007700];
    [/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB]$pagination[/COLOR][COLOR=#007700].= [/COLOR][COLOR=#DD0000]"..."[/COLOR][COLOR=#007700];
    [/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB]for ([/COLOR][COLOR=#0000BB]$counter [/COLOR][COLOR=#007700]= [/COLOR][COLOR=#0000BB]$page [/COLOR][COLOR=#007700]- [/COLOR][COLOR=#0000BB]$adjacents[/COLOR][COLOR=#007700]; [/COLOR][COLOR=#0000BB]$counter [/COLOR][COLOR=#007700]<= [/COLOR][COLOR=#0000BB]$page [/COLOR][COLOR=#007700]+ [/COLOR][COLOR=#0000BB]$adjacents[/COLOR][COLOR=#007700]; [/COLOR][COLOR=#0000BB]$counter[/COLOR][COLOR=#007700]++)
    [/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB]{
    [/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB]if ([/COLOR][COLOR=#0000BB]$counter [/COLOR][COLOR=#007700]== [/COLOR][COLOR=#0000BB]$page[/COLOR][COLOR=#007700])
    [/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB]$pagination[/COLOR][COLOR=#007700].= [/COLOR][COLOR=#DD0000]"<span class=\"current\">$counter</span>"[/COLOR][COLOR=#007700];
    [/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB]else
    [/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB]$pagination[/COLOR][COLOR=#007700].= [/COLOR][COLOR=#DD0000]"<a href=\"$targetpage?page=$counter\">$counter</a>"[/COLOR][COLOR=#007700];[/COLOR][COLOR=#0000BB] [/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB]
    [/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB]}
    [/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB]$pagination[/COLOR][COLOR=#007700].= [/COLOR][COLOR=#DD0000]"..."[/COLOR][COLOR=#007700];
    [/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB]$pagination[/COLOR][COLOR=#007700].= [/COLOR][COLOR=#DD0000]"<a href=\"$targetpage?page=$lpm1\">$lpm1</a>"[/COLOR][COLOR=#007700];
    [/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB]$pagination[/COLOR][COLOR=#007700].= [/COLOR][COLOR=#DD0000]"<a href=\"$targetpage?page=$lastpage\">$lastpage</a>"[/COLOR][COLOR=#007700];[/COLOR][COLOR=#0000BB] [/COLOR][COLOR=#0000BB]
    [/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB]}
    [/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#FF8000]//close to end; only hide early pages
    [/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB]else
    [/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB]{
    [/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB]$pagination[/COLOR][COLOR=#007700].= [/COLOR][COLOR=#DD0000]"<a href=\"$targetpage?page=1\">1</a>"[/COLOR][COLOR=#007700];
    [/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB]$pagination[/COLOR][COLOR=#007700].= [/COLOR][COLOR=#DD0000]"<a href=\"$targetpage?page=2\">2</a>"[/COLOR][COLOR=#007700];
    [/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB]$pagination[/COLOR][COLOR=#007700].= [/COLOR][COLOR=#DD0000]"..."[/COLOR][COLOR=#007700];
    [/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB]for ([/COLOR][COLOR=#0000BB]$counter [/COLOR][COLOR=#007700]= [/COLOR][COLOR=#0000BB]$lastpage [/COLOR][COLOR=#007700]- ([/COLOR][COLOR=#0000BB]2 [/COLOR][COLOR=#007700]+ ([/COLOR][COLOR=#0000BB]$adjacents [/COLOR][COLOR=#007700]* [/COLOR][COLOR=#0000BB]2[/COLOR][COLOR=#007700])); [/COLOR][COLOR=#0000BB]$counter [/COLOR][COLOR=#007700]<= [/COLOR][COLOR=#0000BB]$lastpage[/COLOR][COLOR=#007700]; [/COLOR][COLOR=#0000BB]$counter[/COLOR][COLOR=#007700]++)
    [/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB]{
    [/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB]if ([/COLOR][COLOR=#0000BB]$counter [/COLOR][COLOR=#007700]== [/COLOR][COLOR=#0000BB]$page[/COLOR][COLOR=#007700])
    [/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB]$pagination[/COLOR][COLOR=#007700].= [/COLOR][COLOR=#DD0000]"<span class=\"current\">$counter</span>"[/COLOR][COLOR=#007700];
    [/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB]else
    [/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB]$pagination[/COLOR][COLOR=#007700].= [/COLOR][COLOR=#DD0000]"<a href=\"$targetpage?page=$counter\">$counter</a>"[/COLOR][COLOR=#007700];[/COLOR][COLOR=#0000BB] [/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB]
    [/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB]}
    [/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB]}
    [/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB]}
    [/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB]
    [/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#FF8000]//next button
    [/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB]if ([/COLOR][COLOR=#0000BB]$page [/COLOR][COLOR=#007700]< [/COLOR][COLOR=#0000BB]$counter [/COLOR][COLOR=#007700]- [/COLOR][COLOR=#0000BB]1[/COLOR][COLOR=#007700]) 
    [/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB]$pagination[/COLOR][COLOR=#007700].= [/COLOR][COLOR=#DD0000]"<a href=\"$targetpage?page=$next\">next »</a>"[/COLOR][COLOR=#007700];
    [/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB]else
    [/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB]$pagination[/COLOR][COLOR=#007700].= [/COLOR][COLOR=#DD0000]"<span class=\"disabled\">next »</span>"[/COLOR][COLOR=#007700];
    [/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB]$pagination[/COLOR][COLOR=#007700].= [/COLOR][COLOR=#DD0000]"</div>\n"[/COLOR][COLOR=#007700];[/COLOR][COLOR=#0000BB] [/COLOR][COLOR=#0000BB]
    [/COLOR][COLOR=#0000BB]}
    [/COLOR][COLOR=#0000BB]?>[/COLOR][/COLOR]
    
    
    
    [COLOR=#000000][COLOR=#0000BB]<?php
    echo [/COLOR][COLOR=#DD0000]'<table border="0" style="margin-left:auto;margin-right:auto;margin-top:10px">'[/COLOR][COLOR=#007700];
        echo [/COLOR][COLOR=#DD0000]'<tr>'[/COLOR][COLOR=#007700].[/COLOR][COLOR=#DD0000]' <th style="width:550px">'[/COLOR][COLOR=#007700].[/COLOR][COLOR=#DD0000]'</th>'[/COLOR][COLOR=#007700].[/COLOR][COLOR=#DD0000]'</tr>'[/COLOR][COLOR=#007700];
    [/COLOR][COLOR=#0000BB]
    [/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB]while([/COLOR][COLOR=#0000BB]$row [/COLOR][COLOR=#007700]= [/COLOR][COLOR=#0000BB]mysql_fetch_array[/COLOR][COLOR=#007700]([/COLOR][COLOR=#0000BB]$result[/COLOR][COLOR=#007700]))
    [/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB]{
    [/COLOR][COLOR=#0000BB]
    [/COLOR][COLOR=#FF8000]// Print out the contents of each row into a table
    
    [/COLOR][COLOR=#0000BB]$id[/COLOR][COLOR=#007700]=[/COLOR][COLOR=#0000BB]$row[/COLOR][COLOR=#007700][[/COLOR][COLOR=#DD0000]'id'[/COLOR][COLOR=#007700]];
    [/COLOR][COLOR=#0000BB]$link [/COLOR][COLOR=#007700]= [/COLOR][COLOR=#DD0000]"http://www.brasilwebdesign.com/menu/menu.php?id=$id"[/COLOR][COLOR=#007700];
    [/COLOR][COLOR=#FF8000]//Row begining
    [/COLOR][COLOR=#007700]echo [/COLOR][COLOR=#DD0000]'<tr bgcolor="red">'[/COLOR][COLOR=#007700];
    [/COLOR][COLOR=#FF8000]//LOGO
    [/COLOR][COLOR=#007700]echo [/COLOR][COLOR=#DD0000]'<td style="width:550px" >'[/COLOR][COLOR=#007700]; 
    echo [/COLOR][COLOR=#DD0000]'<img src="images/logo_test.gif" alt="logo" style="margin-right:5px" align ="left" width="140" height="80"/>'[/COLOR][COLOR=#007700];
    [/COLOR][COLOR=#FF8000]//TEXT
    [/COLOR][COLOR=#007700]echo [/COLOR][COLOR=#DD0000]'<a href="'[/COLOR][COLOR=#007700].[/COLOR][COLOR=#0000BB]$link[/COLOR][COLOR=#007700].[/COLOR][COLOR=#DD0000]'".>'[/COLOR][COLOR=#007700].[/COLOR][COLOR=#DD0000]'<u>'[/COLOR][COLOR=#007700].[/COLOR][COLOR=#0000BB]$row[/COLOR][COLOR=#007700][[/COLOR][COLOR=#DD0000]'restaurant_name'[/COLOR][COLOR=#007700]].[/COLOR][COLOR=#DD0000]'</u>'[/COLOR][COLOR=#007700].[/COLOR][COLOR=#DD0000]'</a>'[/COLOR][COLOR=#007700];     
    echo [/COLOR][COLOR=#DD0000]'<br>'[/COLOR][COLOR=#007700];
    echo [/COLOR][COLOR=#0000BB]$row[/COLOR][COLOR=#007700][[/COLOR][COLOR=#DD0000]'about'[/COLOR][COLOR=#007700]];
    echo [/COLOR][COLOR=#DD0000]'<br>'[/COLOR][COLOR=#007700];
    echo [/COLOR][COLOR=#DD0000]'<b>'[/COLOR][COLOR=#007700].[/COLOR][COLOR=#0000BB]$row[/COLOR][COLOR=#007700][[/COLOR][COLOR=#DD0000]'address'[/COLOR][COLOR=#007700]].[/COLOR][COLOR=#DD0000]'</b>'[/COLOR][COLOR=#007700];
    echo [/COLOR][COLOR=#DD0000]'</td>'[/COLOR][COLOR=#007700];
    
    
    [/COLOR][COLOR=#FF8000]//Row end
    [/COLOR][COLOR=#007700]echo [/COLOR][COLOR=#DD0000]'</tr>'[/COLOR][COLOR=#007700]; 
    }
    
    echo [/COLOR][COLOR=#DD0000]'</table>'[/COLOR][COLOR=#007700];
    [/COLOR][COLOR=#0000BB]
    [/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#0000BB]?>[/COLOR][/COLOR]
    
    <?=$pagination?>
    [/COLOR]
  • navaldesign
    General & Forum Moderator

    • Oct 2005
    • 12080

    #2
    Re: pagination problem

    Your links to the next pages miss the category and subcategory so the script finds nothing. Try seeing the second page for restaurants, Japanese, as http://www.brasilwebdesign.com/menu/...it=Find&page=2

    And you will see that it works
    Navaldesign
    Logger Lite: Low Cost, Customizable, multifeatured Login script
    Instant Download Cart: a Powerfull, Customized, in site, DB driven, e-products Cart
    DBTechnosystems.com Forms, Databases, Shopping Carts, Instant Download Carts, Loggin Systems and more....
    Advanced BlueVoda Form Processor : No coding form processor! Just install and use! Now with built in CAPTCHA!

    Comment

    • dannysheps@hotmail.com
      Second Lieutenant

      • Feb 2008
      • 138

      #3
      Re: pagination problem

      thanks

      that was it.

      Comment

      Working...
      X