Jump to content

[SOLVED] pagination


spooke2k

Recommended Posts

i am trying to use a pagination script that is from a tutorial on here i was given a link to and basically i can get information to display on first page and it brings up standard text saying under PREV5 1 NEXT5 but it isnt a link or interactive so i cant get next 5 records or last so i have 5 records on screen but cant navigate between them.

But i cant see why the screen shows only 5 records there are no error codes can anyone see what i have done wrong please as i feel like im going round in a circle.

 

thanks spooke2k

 

    $limit          = 5;             

    $query_count    = "SELECT count(*) FROM pressimagelink where Cat = 1 ";   

    $result_count  = mysql_query($query_count);   

    $totalrows      = mysql_num_rows($result_count);

 

    if(empty($page)){

        $page = 1;

    }

       

    $limitvalue = $page * $limit - ($limit);

    $query  = "select * from pressimagelink where Cat = 1 order by productcode asc LIMIT $limitvalue, $limit";       

    $result = mysql_query($query) or die("Error: " . mysql_error());

 

    if(mysql_num_rows($result) == 0){

        echo("Nothing to Display!");

    }

 

    $bgcolor = "#E0E0E0"; // light gray

 

    echo("<table>");

   

    while($row = mysql_fetch_array($result)){

     

    if ($bgcolor == "#E0E0E0"){

            $bgcolor = "#FFFFFF";

        }else{

            $bgcolor = "#E0E0E0";

        }

 

echo("<tr bgcolor=".$bgcolor."><td>");

echo "<td>{$row['prozenid']}</td>";

echo "<td>{$row['productcode']}</td>";

echo "<td>£{$row['price']}</td>";

echo "</tr>";

 

 

    }

   

    echo("</table>");

 

if($page != 1){

        $pageprev = $page--;

       

        echo("<a href=\"$PHP_SELF&page=$pageprev\">PREV".$limit."</a> ");

    }else{

        echo("PREV".$limit." ");

    }

 

    $numofpages = $totalrows / $limit;

   

    for($i = 1; $i <= $numofpages; $i++){

        if($i == $page){

            echo($i." ");

        }else{

            echo("<a href=\"$PHP_SELF?page=$i\">$i</a> ");

        }

    }

 

 

    if(($totalrows % $limit) != 0){

        if($i == $page){

            echo($i." ");

        }else{

            echo("<a href=\"$PHP_SELF?page=$i\">$i</a> ");

        }

    }

 

    if(($totalrows - ($limit * $page)) > 0){

        $pagenext = $page++;

       

        echo("<a href=\"$PHP_SELF?page=$pagenext\">NEXT".$limit."</a>");

    }else{

        echo("NEXT".$limit);

    }

    mysql_free_result($result);

 

?>

</form>

Link to comment
https://forums.phpfreaks.com/topic/54410-solved-pagination/
Share on other sites

no sorry thats not what i mean

 

the 5 records to page is correct but then if i was to click next 5 it doesnt work the

" next"  working is i presume the navigation link and its just txt and  so is pervious so i can't  navigate to say page 2 etc.

its literally just displaying as text as opposed to a means to asking for next records etc.

Hope this clears this up

 

Colin

 

 

Link to comment
https://forums.phpfreaks.com/topic/54410-solved-pagination/#findComment-269041
Share on other sites

well in the config file you put the details such as $username, $password, $host, $database and then the opendb is just you connection to the database so

 

	$con = mysql_connect ( $host, $username, $password ) or
	die (mysql_error());
mysql_select_db ($database) or
	die (mysql_error());

 

So really all the includes are doing is including the files that connect you to the database

 

Hope it helps,

 

~ Chocopi

Link to comment
https://forums.phpfreaks.com/topic/54410-solved-pagination/#findComment-269067
Share on other sites

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.