ionnnnutz Posted April 23, 2007 Share Posted April 23, 2007 can somebody take a look at this code and help me see where is the problem? i get all the data but the links to next/prev page doesn't appear. <?php require ('includes/connect.php'); $limit = 5; $query_count = "SELECT count(*) FROM comp, comp_pnote WHERE comp.comp_id = comp_pnote.comp_notesid and comp.comp_id ='".$ID."'"; $result_count = mysql_query($query_count); $totalrows = mysql_num_rows($result_count); if(empty($page)){ $page = 1; } $limitvalue = $page * $limit - ($limit); $query =("SELECT comp.comp_nume,date_format(comp_pnote.comp_note_entry_date, '%W') as entry_date,date_format(comp_pnote.comp_note_entry_date, '%d.%m.%Y') as entry_date2,date_format(comp_pnote.comp_note_entry_date, '%H:%i') as entry_date3,comp_pnote.comp_note_message from comp, comp_pnote WHERE comp.comp_id = comp_pnote.comp_notesid and comp.comp_id ='".$ID."' ORDER BY entry_date2 DESC 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)){ $entry_date = $row["entry_date"]; $message = $row["comp_note_message"]; $entry_date2 = $row["entry_date2"]; $entry_date3 = $row["entry_date3"]; if ($bgcolor == "#E0E0E0"){ $bgcolor = "#FFFFFF"; }else{ $bgcolor = "#E0E0E0"; } echo("<tr bgcolor=".$bgcolor.">n<td>"); echo($entry_date); echo("</td>n<td>"); echo($message); echo("</td>n</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=\"$testnoteinpagina.php?ID='$id'?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); Quote Link to comment https://forums.phpfreaks.com/topic/48253-i-dont-have-the-links-for-nextprev-page/ Share on other sites More sharing options...
MadTechie Posted April 23, 2007 Share Posted April 23, 2007 <?php if(empty($page)){ $page = 1; } ?> your not setting $page Quote Link to comment https://forums.phpfreaks.com/topic/48253-i-dont-have-the-links-for-nextprev-page/#findComment-235900 Share on other sites More sharing options...
ionnnnutz Posted April 23, 2007 Author Share Posted April 23, 2007 i don't understand Quote Link to comment https://forums.phpfreaks.com/topic/48253-i-dont-have-the-links-for-nextprev-page/#findComment-235902 Share on other sites More sharing options...
MadTechie Posted April 23, 2007 Share Posted April 23, 2007 ok i assume you didn't write the script.. add <?php $page = 2; ?> at the top, 2 can be anynumber except 0, 1 will display all records without a prev & next Note: I would find another paging system Quote Link to comment https://forums.phpfreaks.com/topic/48253-i-dont-have-the-links-for-nextprev-page/#findComment-235905 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.