Jump to content

volatileboy

Members
  • Posts

    55
  • Joined

  • Last visited

    Never

Everything posted by volatileboy

  1. I can't think of a logical way of doing this so I appreciate any help! I am trying to sort some information from the database by ip address but for obvious reasons it does not sort the ips in a propper order for example the ips get listed like this: 200.113.178.11 208.38.116.185 208.38.116.185 208.38.116.185 208.38.116.185 208.38.116.185 217.136.72.105 217.136.72.105 24.163.230.170 24.174.109.231 24.192.226.76 24.218.120.66 62.195.222.41 64.231.213.222 I am just using a straight forward: ORDER BY ip ASC query for this, I really dont know how I could get this to work, thanks in advance!
  2. thank you mucho dude, thats exactly what I needed to hear. Thanks for clarifying that for me, should work now :)
  3. the values are correct: PAGE 1 $min = ($page * $numperpage - $numperpage); [b]which is (1 * 40 - 40) = 0[/b] $max = ($page * $numperpage - 1); [b]which is (1 * 40 - 1) = 39[/b] I dont see how that can be absurd, and yes its pagination so its dynamically generated min and max values, however the above is not absurd, ive echoed the values and they come out exactly as above so I am clueless how you came to "-1"
  4. It has to be done mathmatically otherwise the pagination wont work, I echoed the $min and $max values and they show correctly however the results are not coming out like that. $min = ($page * $numperpage - $numperpage); << this is correct cos page 1 would have a value of 0 and page 2 would have a value of 40 $max = ($page * $numperpage - 1); << this is correct cos page 1 would have a value of 39 and page 2 would have a value of 79 Thats why I am so baffled with this because I dont understand why its doing it, ive used pagination so many times before and not had this problem.
  5. Okay I have been playing with this for ages now and it doesnt appear to work correctly, I have it to show 40 entries per page and it works correct on page 1 showing results 0-39, however on page 2 it shows results 40-84 and I have no idea why its doing it, here is the code I am using... please bare in mind that what im talking about above is not using the $cat variable. here is the code: [code] <?         if(isset($_GET['cat'])) {             $cat = $_GET['cat'];             $sql = "SELECT * FROM poems WHERE type='$cat'";                 } else {                     $sql = "SELECT * FROM poems";                 }                 $res = mysql_query($sql);                 $numperpage = 40;                 $num = mysql_num_rows($res);                 $numpages1 = ($num / $numperpage);                 $numpages = ceil($numpages1);                 if(isset($_GET['page'])) {                     $page = $_GET['page'];                 } else {                     $page = 1;                 }                 $min = ($page * $numperpage - $numperpage);                 $max = ($page * $numperpage - 1);                 if(isset($_GET['cat'])) {                     $q = "SELECT * FROM poems WHERE type='$cat' LIMIT $min,$max";                 } else {                     $q = "SELECT * FROM poems LIMIT $min,$max";                 }                 $result = mysql_query($q);                 if($page == 1) {                     $count = 1;                 } else {                     $count = $min;                 }                 while($row = mysql_fetch_array($result)) {                     $id = $row["id"];                     $title = $row["title"];                     echo "<tr><td><div align=\"center\">$count</div></td><td>&nbsp;<a href=\"viewpoem.php?id=$id\">$title</a></td></tr>";                     $count++;                 }                 echo '</table>';                 //pagination                 $r = 1;                 echo "<br><br><b>Jump To Page:<br>|&nbsp;&nbsp;";                 while($r <= $numpages) {                     if(isset($_GET['cat'])) {                         if($r == $page) {                             echo "<span class=\"paginationred\">[$r]</span>&nbsp&nbsp;";                         }                         if($r != $page) {                             echo "<a href=\"$PHPSELF?cat=$cat&page=$r\" class=\"pagination\">$r</a>&nbsp;&nbsp;";                         }                     } else {                         if($r == $page) {                             echo "<span class=\"paginationred\">[$r]</span>&nbsp;&nbsp;";                         }                         if($r != $page) {                             echo "<a href=\"$PHPSELF?page=$r\" class=\"pagination\">$r</a>&nbsp;&nbsp;";                         }                     } // end if                     $r++;                 } // end loop                 echo '|';                 ?> [/code] Any help is appreciated, thanks
×
×
  • 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.