spooke2k Posted June 6, 2007 Share Posted June 6, 2007 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> Quote Link to comment https://forums.phpfreaks.com/topic/54410-solved-pagination/ Share on other sites More sharing options...
mmarif4u Posted June 6, 2007 Share Posted June 6, 2007 if i understand u correctly u mean that ur code show 5 records per page. So change this to ur desire one: $limit = 5; i change it to 20, it will show u 20 records per page. $limit = 20; Quote Link to comment https://forums.phpfreaks.com/topic/54410-solved-pagination/#findComment-269039 Share on other sites More sharing options...
spooke2k Posted June 6, 2007 Author Share Posted June 6, 2007 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 Quote Link to comment https://forums.phpfreaks.com/topic/54410-solved-pagination/#findComment-269041 Share on other sites More sharing options...
mmarif4u Posted June 6, 2007 Share Posted June 6, 2007 Try to read and implement this to ur code its easy and better. http://www.php-mysql-tutorial.com/php-mysql-paging.php Quote Link to comment https://forums.phpfreaks.com/topic/54410-solved-pagination/#findComment-269047 Share on other sites More sharing options...
spooke2k Posted June 6, 2007 Author Share Posted June 6, 2007 it cant find include 'library/config.php'; include 'library/opendb.php'; i cant seem to dind them on my system ? i get them are include functions but where are they if there cusom how can i work out what i need strange. Spooke2k Quote Link to comment https://forums.phpfreaks.com/topic/54410-solved-pagination/#findComment-269064 Share on other sites More sharing options...
chocopi Posted June 6, 2007 Share Posted June 6, 2007 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 Quote Link to comment https://forums.phpfreaks.com/topic/54410-solved-pagination/#findComment-269067 Share on other sites More sharing options...
spooke2k Posted June 6, 2007 Author Share Posted June 6, 2007 thanks for help got it working now Spooke2k Quote Link to comment https://forums.phpfreaks.com/topic/54410-solved-pagination/#findComment-269069 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.