thryb Posted September 6, 2007 Share Posted September 6, 2007 Good day, Im trying to include paging in my script but I always get the same results. Anyone can see what is wrong with my script ? I get no error, only the same results every page. Thanks much in advance! <?php $con = mysql_connect("localhost","wb_usr","xxx"); if (!$con){ die('Could not connect: ' . mysql_error()); } mysql_select_db("wb", $con); function protect($input) { $input = mysql_real_escape_string($input); $input = eregi_replace("%","",$input); $input = eregi_replace("--","",$input); $input = htmlspecialchars(mysql_real_escape_string($input)); return $input; } $_COOKIE = array_map("protect",$_COOKIE); array_map('mysql_real_escape_string', $_POST); array_map('mysql_real_escape_string', $_GET); ///////////////////////////////////////////////////////////////////////////// if (isset($_GET[“page”])) { $page = $_GET[“page”]; } else { $page=1; }; $start_from = ($page-1) * 20; ///////////////////////////////////////////////////////////////////////////// $sql = "SELECT * FROM Comment ORDER BY CommDT DESC LIMIT $start_from, 2"; $result = mysql_query($sql,$con); while ($row = mysql_fetch_assoc($result)) { $ID = Protect(mysql_result($result,$i,"CommID")); $subject = Protect(mysql_result($result,$i,"CommSubject")); $name = Protect(mysql_result($result,$i,"PartName")); $fname = Protect(mysql_result($result,$i,"PartFirstName")); $country = Protect(mysql_result($result,$i,"PartCountry")); $city = Protect(mysql_result($result,$i,"PartCity")); $phone = Protect(mysql_result($result,$i,"PartPhone")); $fax = Protect(mysql_result($result,$i,"PartFax")); $text = Protect(mysql_result($result,$i,"CommText")); $link = Protect(mysql_result($result,$i,"CommLink")); $mail = Protect(mysql_result($result,$i,"CommMail")); $DT = Protect(mysql_result($result,$i,"CommDT")); $pic = Protect(mysql_result($result,$i,"CommPic")); echo '<br>'; echo '<table width="800" border="0" cellpadding="3" cellspacing="0" class="text">'; echo ' <tr bgcolor="#C5B478">'; echo ' <td width="101"><font color="#000000"><strong>Subject :</strong></font></td>'; echo ' <td width="300">'.$subject.'</td>'; echo ' <td align="left"><font color="#000000"><strong>Date/Time :</strong></font></td>'; echo ' <td align="left">'.$DT.'</td>'; echo ' </tr>'; if ($fname != ""){ echo ' <tr> '; echo ' <td width="101"><font color="#000000"><strong>Name :</strong></font></td>'; echo ' <td width="167">'.$fname.'</td>'; } if ($name != ""){ echo ' <td width="101"><font color="#000000"><strong>Last Name :</strong></font></td>'; echo ' <td width="127" align="left">'.$name.'</td>'; echo ' </tr>'; } if ($phone != ""){ echo ' <tr> '; echo ' <td width="101"><font color="#000000"><strong>Phone :</strong></font></td>'; echo ' <td>'.$phone.'</td>'; } if ($fax != ""){ echo ' <td width="101"><font color="#000000"><strong>Fax :</strong></font></td>'; echo ' <td align="left">'.$fax.'</td>'; echo ' </tr>'; } if ($country != ""){ echo ' <tr> '; echo ' <td width="101"><font color="#000000"><strong>Country :</strong></font></td>'; echo ' <td>'.$country.'</td>'; } if ($city != ""){ echo ' <td width="101"><font color="#000000"><strong>City :</strong></font></td>'; echo ' <td align="left">'.$city.'</td>'; echo ' </tr>'; } if ($mail != ""){ echo ' <tr> '; echo ' <td width="101"><font color="#000000"><strong>Email :</strong></font></td>'; echo ' <td>'.$mail.'</td>'; } if ($link != ""){ echo ' <td width="101"><font color="#000000"><strong>Website :</strong></font></td>'; echo ' <td align="left"><a href="http://'.$link.'">'.$link.'</a></td>'; echo ' </tr>'; } if ($text != ""){ echo ' <tr> '; echo ' <td valign="top"><font color="#000000"><strong>Comment :</strong></font></td>'; echo ' <td colspan="3">'.$text.'</td>'; echo ' </tr>'; } if ($pic != ""){ echo ' <tr> '; echo ' <td colspan="3" width="101">'; echo '<img src="getJpeg.php?id='.$ID.'" alt="Comment picture." />'; echo '</td>'; echo ' </tr>'; } echo '</table>'; echo '<br>'; } $sql = "SELECT COUNT(CommID) FROM Comment"; $rs_result = mysql_query($sql,$con); $row = mysql_fetch_row($rs_result); $total_records = $row[0]; $total_pages = ceil($total_records / 2); for ($i=1; $i<=$total_pages; $i++) { echo "<a href='theletter.php?page=".$i."'>".$i. "</a>"; }; ?> Link to comment https://forums.phpfreaks.com/topic/68209-solved-paging-return-always-same-result/ Share on other sites More sharing options...
thryb Posted September 6, 2007 Author Share Posted September 6, 2007 Got it sorry guys, was a typo $start_from = ($page-1) * 20; insteed of $start_from = ($page-1) * 2; (2 is for test purpose) Sorry about that Link to comment https://forums.phpfreaks.com/topic/68209-solved-paging-return-always-same-result/#findComment-342913 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.