Welcome to Dream.In.Code
Getting PHP Help is Easy!

Join 135,948 PHP Programmers for FREE! Get instant access to thousands of PHP experts, tutorials, code snippets, and more! There are 2,707 people online right now. Registration is fast and FREE... Join Now!




PHP Code is not pulling correct pagination numbers

 
Reply to this topicStart new topic

PHP Code is not pulling correct pagination numbers

WrestleTalkRadio
19 May, 2008 - 07:31 PM
Post #1

New D.I.C Head
*

Joined: 19 May, 2008
Posts: 2

Hi:

I am an idiot-savant when it comes to coding. I had a script made by someone who didnt know what he was doing, exactly, and for some reason the coding wont work properly. I've looked at everything I could find and nothing has helped me figure this out.

Basically, I have a columns page that will preview the featured column, with a link to click to read the rest, then 20 separate column titles underneath this. Below this, a series of numbers to click to go to different pages with older posts (naturally). What is supposed to happen is that you click the number to go to that page (say 21 to 31), but all that happens is the same list of blog titles that are on the "first page". Take a look here: http://www.wildtalkradio.com/columns.php. Click the pagination numbers and you'll see what I mean.

Here is the FULL code for this:

CODE
<? $result = mysql_query("SELECT * FROM `columns`"); $total = mysql_num_rows($result);
              if(isset($_GET['less'])) { $less = $_GET['less']; } else { $less
              = 0; } if(isset($_GET['high'])) { $high = $_GET['high']; } else
              { $high = 15; } ?>
                </font><font color="#000000">
                <?php
if($result = mysql_query("SELECT * FROM `columns` WHERE featured = 1")) {
    $myrow = mysql_fetch_array($result);
    $main = substr($myrow['main'], 0, 900);
    $user = $myrow['user'];
    $userr = mysql_query("SELECT * FROM admin WHERE id = '$user'");
    $user = mysql_result($userr,0,'name');
    ?>
                <i><b><a href="./columnview.php?id=<?php echo $myrow['id'] ?>"><?php echo $myrow['title'] ?></a></b></i></font></font></div>
              <div align="justify">
<p><font color="#000000" size="2">Posted on <?php echo $myrow['date'] ?></font><font color="#000000"><br>
                  <font size="2">by <?php echo $user ?>.<br>
                  <br>
                  </font></font> <font color="#000000"><?php echo $main ?>...<br>
                  <font size="1"> <a href="./columnview.php?id=<?php echo $myrow['id'] ?>"><b><i>View
                  the Rest</i></b></a> </font></font> </p>
                <div align="justify"><font color="#000000" size="1" face="Verdana, Arial, Helvetica, sans-serif">
                  <?php
} else {
    ?>
                  Error retrieving featured column.</font><font color="#000000" face="Verdana, Arial, Helvetica, sans-serif"><font size="1">
                  <?php
}
if($result = mysql_query("SELECT * FROM `columns` ORDER BY date DESC LIMIT 20")) {
    while($myrow = mysql_fetch_array($result)) {
        if($myrow['featured'] != 1) {
            ?>
                  <a href="./columnview.php?id=<?php echo $myrow['id'] ?>"><b><?php echo $myrow['title'] ?></b></a><br>
                  <?php
   }
     }
} else {
    ?>
                  Error retrieivng column list.
                  <?php
}

?>
                  <br>
                  <?php
for($i=1, $n=0;$i<=$total;$i+=20, $n++) {
    if($i == $less) {
        ?>
                  <?php echo $n ?>
                  <?php
                  
    } else {
        ?>
                  <a href="./columns.php?less=<?php echo $i ?>&high=<?php echo ($i+20) ?>"><?php echo $n ?></a>
                  <?php
    }
}
?>



This looks a little ugly to me, and I cannot find the fault anywhere... Can someone help?????

User is offlineProfile CardPM
+Quote Post

no2pencil
RE: PHP Code Is Not Pulling Correct Pagination Numbers
19 May, 2008 - 07:50 PM
Post #2

My fridge be runnin OH NOEZ!
Group Icon

Joined: 10 May, 2007
Posts: 6,433



Thanked: 64 times
Dream Kudos: 2425
Expert In: Goofing Off

My Contributions
Since you are sending HIGH & LESS vales via the $_GET variables, why are you selecting the entire database (SELECT *) every time? Just use between.

http://www.wildtalkradio.com/columns.php?l...41&high=461
CODE

mysql_query("SELECT * FROM `columns` where featured = '1' and **Column Name** between $_GET['less'] and $_GET['high']")



User is offlineProfile CardPM
+Quote Post

WrestleTalkRadio
RE: PHP Code Is Not Pulling Correct Pagination Numbers
19 May, 2008 - 08:00 PM
Post #3

New D.I.C Head
*

Joined: 19 May, 2008
Posts: 2

QUOTE(no2pencil @ 19 May, 2008 - 08:50 PM) *

Since you are sending HIGH & LESS vales via the $_GET variables, why are you selecting the entire database (SELECT *) every time? Just use between.

http://www.wildtalkradio.com/columns.php?l...41&high=461
CODE

mysql_query("SELECT * FROM `columns` where featured = '1' and **Column Name** between $_GET['less'] and $_GET['high']")



Thank you for this, and I am sure that that is what will work, but not sure where to place it. One thing I forgot to mention is the first part of this code sets a Featured column. This is not the latest posted column, but it is an option in the back end (admin section) for me to set any random column as a featured one, regardless of when it was posted. Does that make a difference?
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 12/1/08 08:56AM

Live PHP Help!

PHP Tutorials

Reference Sheets

PHP Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month