Jump to content

next and previous functions do not work


lpfix2007

Recommended Posts

the site link is www.fcirc.net/banners.php when the site loads it should bring me to ?id=1 then i should proceed to click Next Next etc.. or Prev however my its not working. But if I type www.fcirc.net/banners.php?id=21 and then click prev it will previous its way to 1 but the next function still does not work. I've tryed so many times and failed I would be wondering if anyone could shed some light.

 

Thanks in Advance here is the PHP code

 

<?PHP
include("dbinfo.php");
$cid=$_GET['id'];
@mysql_connect($host, $username, $password) or die("ERROR--CAN'T CONNECT TO SERVER");
@mysql_select_db("$dbName") or die("ERROR--CAN'T CONNECT TO DB"); 
$limit      = 400;  
$query_count    = "SELECT count(*) FROM banners";    
$result_count   = mysql_query($query_count);    
$totalrows  = mysql_num_rows($result_count); 

    if(empty($page)){    
        $page = 1;      
    }
    $limitvalue = $page * $limit - ($limit); 
    $query  = "SELECT * FROM banners LIMIT $limitvalue, $limit";        
    $result = mysql_query($query) or die("Error: " . mysql_error()); 
    if(mysql_num_rows($result) == 0){
        echo("Nothing to Display!");
    }
    if($page != $cid){ 
        $pageprev = $cid--;
        echo("<span class='style108'><b>(</b></span><span class='style106'>$pageprev</span><span class='style108'><b>)</b></span> ");  
    }else
        echo("$pageprev"); 
        $numofpages = $totalrows / $limit; 
    for($i = $cid; $i <= $numofpages; $i++){
       if($i == $page){
            echo($i." ");
        }else{
            echo("<a href=\"$PHP_SELF?id=$cid\">Prev</a> <b>|</b> "); 
        }
    } 
if(($totalrows % $limit) != 0){
       if($i == $page){
            echo($i." ");
        }else{
            echo("<a href=\"$PHP_SELF?id=$cid\">Prev</a> <b>|</b> ");
        }
        }
 if(($totalrows + ($cid * $page)) != $limit){
    $pagenext = $cid++;
        echo("<a href=\"$PHP_SELF?id=$pagenext\">Next</a>");
        }else{
        echo("Next"); 
    }
mysql_free_result($result);
?>

Link to comment
https://forums.phpfreaks.com/topic/38128-next-and-previous-functions-do-not-work/
Share on other sites

Try this little script:

 

<?php
$a = 1;
$b = $a++;
print "a = $a, b = $b\n";
$b = ++$a;
print "a = $a, b = $b\n";
?>

 

Note that putting ++ after the variable will increment the variable AFTER assigning $b.  Putting it before will increment before assigning $b.

hmmm all my php work i did beofre is ok except im still having issues with this one,

 

I know in that example that your creating a var named A then B Which increments A then A is printed etc.. still does not funtion in the next or prev functions either it goes back or forward

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.