Re: << Previous n Articles

From: Date: Wed, 06 Feb 2002 03:38:54 +0000
Subject: Re: << Previous n Articles
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-83669@lists.php.net to get a copy of this message
On Wednesday 06 February 2002 09:59, jtjohnston wrote: > I'm using this code to create a "Next n Articles >>" on my index.page > from my mysql database. > I worked most of it out myself. Then I got some help. It works. I > thought I understood my own code enough to be able to construct a "<< > Previous n Articles". I guess not. My coding skills need help. > So how do I reverse my code to construct the previous n articles from my > sql database. > > if(!$offset) > { > $offset = 0; > } > $limit = 5; > $num_rows = 13;#I get this from a mysql operation > > ##################################################### > $new_offset = $offset + $limit; > $disp = $limit; > if ($new_offset + $limit > $num_rows) > { > $disp = $num_rows - $new_offset; > } > if ($disp > 0) > { > $nextinsert = " <font face=\"arial\" size=2><A > HREF=\"index.html?offset=".$new_offset."\">Next ".$disp." > Articles > &gt;&gt;</a></font>\n"; > } > Something like: $previous = $offset - $limit; if ($previous < 0) { $previous = 0; } then incorporate $previous into your previous link in a similar fashion to the next link. hth -- Jason Wong -> Gremlins Associates -> www.gremlins.com.hk /* Random, n.: As in number, predictable. As in memory access, unpredictable. */

« previous php.general (#83669) next »