ArjanR Posted April 30, 2006 Share Posted April 30, 2006 Hi,I'm new here and also a newbee in the world of php. I tried looking through the forum's archive if I could find topics dealing with my problem, but I couldn't find one (although I know they exist cos it's quite a basic question I think.)Anyway, what I am looking for is a way to spread out entries from a database over multiple pages, and being able to switch back and forth between those pages via "Previous 25 entries" and "Next 25 entries" at the bottom of the page.The page it is for uses the following code to retrieve the last 25 entries (pictures) out the database:(The actual website page is visible here: [a href=\"http://www.plasticdaisy.net/last25.php)\" target=\"_blank\"]http://www.plasticdaisy.net/last25.php)[/a]<?if (! $archive) {$res = mysql_query("SELECT COUNT(*) FROM photo", $con);$row = mysql_fetch_array($res);$total = $row[0];$nr = $total - 5;$res = mysql_query("SELECT * FROM photo ORDER BY msgid DESC LIMIT $nr, $total", $con);$res = mysql_query("SELECT * FROM photo ORDER BY msgid DESC LIMIT 25", $con);} else {$res = mysql_query("SELECT * FROM photo ORDER BY msgid DESC", $con);}while ($row = mysql_fetch_array($res)) {$msgid = $row["msgid"];echo "<br>";echo "<table width=100% border=0 cellpadding=0 cellspacing=0>";echo "<tr><td colspan=4 align=center>";echo "<b>" . strip_tags($row["title"]) . "</b>" . "<br>";echo "<br><a href=\"index.php?msgid=$msgid\"><img border=0 src=/images/digicam/" . strip_tags($row["url"]) . " class=red alt='Click to read comments'>" . "</a>";echo "</td></tr>";echo "<tr><td width=45></td><td>";$msgdate = $row["msgdate"];list ($year, $month, $day, $hours, $minutes, $seconds ) = split ('[-: ]', $msgdate);echo "$day-$month-$year";echo "</td><td align=right> ";$res2 = mysql_query("SELECT count(*) FROM photoremarks WHERE msgid=$msgid", $con);$row2 = mysql_fetch_array($res2);echo "<a href=\"index.php?msgid=$msgid\">comments: " . $row2[0] . "</a>" . "<br>";echo " </td><td width=45></td></tr>" . "<br>";echo "</table>";echo "<br><img src=img/onder.gif>";echo "<br>";}mysql_free_result($res);?>Does somebody have a suggestion how I can reuse this page as a basis, so just by giving the links for "Next 25" and "Previous 25" some extra parameter with which a query on the database is defined.Hope I explained it clearly! Any help is welcome! Thanks in advance.Arjan Quote Link to comment 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.