Jump to content


Photo

how to display 15 results, then a new page?


  • Please log in to reply
3 replies to this topic

#1 mATOK

mATOK
  • Members
  • PipPipPip
  • Advanced Member
  • 84 posts
  • LocationToronto, Ontario

Posted 16 August 2006 - 02:32 PM

Hi, I would like to modify the following code so that I output the first 15 results, then build a new page for the next 15 and so on. I would also like to have a link at the bottom that shows like page numbers and arrows back and forth.

I guess firstly I need to know how to output only 15 and then build a new page if necessary.

$eventid=$_POST['eventid'];
$section=$_POST['section'];
$note1=$_POST['note1'];
$note2=$_POST['note2'];
if (!$sort) {
        $q="SELECT * FROM print_notes ORDER BY effective_date DESC";
}
if (!strcmp($sort, 'date')) {
        $q="SELECT * FROM print_notes ORDER BY date DESC";
}
elseif (!strcmp($sort, 'edate')) {
        $q="SELECT * FROM print_notes ORDER BY effective_date";
}
elseif (!strcmp($sort, 'class')) {
        $q="SELECT * FROM print_notes ORDER BY class";
}
elseif (!strcmp($sort, 'company')) {
        $q="SELECT * FROM print_notes ORDER BY company";
}
elseif (!strcmp($sort, 'media')) {
        $q="SELECT * FROM print_notes ORDER BY media";
}

$rez=mysql_query($q) or die (mysql_error());
if (mysql_num_rows($rez) == 0){
        echo "<p>Currently there is no print notes</p>";
}
else {
        while ($i = mysql_fetch_array($rez)) {


                                $img = $i['file'];
                                echo "<table border=\"1\" width=700 style=\"border-collapse:collapse\" align=\"center\">";
                                echo "<tr><th class=\"pnotes\">Date</th><td class=\"pnotestd\">".$i['date']."</td>";

                                if ($path == $i['file']) {
                                        echo "<td rowspan=\"9\" align=\"center\">NO IMAGE TO DISPLAY";
                                        echo "</td></tr>";
                                }
                                else {
                                        echo "<td rowspan=\"9\" align=\"center\"><a href=".$i['file']." target=_blank>";
                                        echo _imgResize($img, "225");
                                        echo "</a></td></tr>";
                                }
                                echo "<tr><th class=\"pnotes\">Effective Date</th><td class=\"pnotestd\">".$i['effective_date']."</td></tr>";
                                echo "<tr><th class=\"pnotes\">Issue</th><td class=\"pnotestd\">".$i['issue']."</td></tr>";
                                echo "<tr><th class=\"pnotes\">Class</th><td class=\"pnotestd\">".$i['class']."</td></tr>";
                                echo "<tr><th class=\"pnotes\">Company</th><td class=\"pnotestd\">".$i['company']."</td></tr>";
                                echo "<tr><th class=\"pnotes\">Media</th><td class=\"pnotestd\">".$i['media']."</td></tr>";
                                echo "<tr><th class=\"pnotes\">Instruction</th><td class=\"pnotestd\">".$i['instruction']."</td></tr>";
                                echo "<tr><td colspan=\"2\">&nbsp;</td></tr>";
                                echo "<tr><td class=\"pnotes\" colspan=\"2\">Entered By: ".$i['user']."</td></tr>";
                                echo "<tr><th class=\"pnotes\" colspan=\"2\"><b><a href=upload/upload.php?eventid=".$i['print_note_num']."><i>EDIT THIS NOTE</i></a></th></tr>";
                                echo "</table>";
                                echo "<br />";
        }
}


"Not everything that counts can be counted, and not everything that can be counted counts."

W3 Web Tutorials | Check Your html | CSS layout techniques | ALA | Zen Garden | CSS Links

Navs with flavor | CSS Playground | CSS boxes

#2 brown2005

brown2005
  • Members
  • PipPipPip
  • Advanced Member
  • 943 posts

Posted 16 August 2006 - 02:33 PM

read up on the pagnation tutorial mate... easy to use as i new nothing and got it straight away

#3 mATOK

mATOK
  • Members
  • PipPipPip
  • Advanced Member
  • 84 posts
  • LocationToronto, Ontario

Posted 16 August 2006 - 02:45 PM

I did not know one existed, thanx :)
"Not everything that counts can be counted, and not everything that can be counted counts."

W3 Web Tutorials | Check Your html | CSS layout techniques | ALA | Zen Garden | CSS Links

Navs with flavor | CSS Playground | CSS boxes

#4 brown2005

brown2005
  • Members
  • PipPipPip
  • Advanced Member
  • 943 posts

Posted 16 August 2006 - 02:48 PM

yeah goto www.phpfreaks.com and select tutorials and then pagnation




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users