This is a little bit more involved then the subject would let on. What I have
is a picture page, has nothing to do with an 80's themed kids show starring
Bill Cosby, but what it has to deal with is a search results like page where 5
images will appear with a next and prev link to get to more. However what I
need to do extra is if someone clicks in from a link for a particular picture
I need to display that pic first. So below is my psudocode.
$numresults = mysql_query("SELECT * FROM images WHERE approved = 1");
$numrows = mysql_num_rows($numresults);
if (empty($offset)) {
$offset=0;
}
// end entry
$sqlquery = "SELECT * FROM images WHERE approved = 1 ORDER BY imageId DESC
limit $offset,$limit";
$result = mysql_query($sqlquery);
while ($search_return = mysql_fetch_array($result)) {
print the images here
}
//mysql_free_result($result);
print $search_results;
// entry for results
$pages = intval($numrows/$limit);
if ($numrows%$limit) {
$pages++;
}
for ($i=1;$i<=$pages;$i++) {
$newoffset=$limit*($i-1);
print "<a href=\"$PHP_SELF?offset=$newoffset&sc=searchResults\">$i</a> \n";
}
if ($offset>1) {
$prevoffset=$offset-$limit;
print "<a href=\"$PHP_SELF?offset=$prevoffset&sc=searchResults\">$Prev</a>
\n";
}
if ($numrows>($offset+$limit)) {
$nextoffset=$offset+$limit;
print "<a href=\"$PHP_SELF?
offset=$nextoffset&sc=searchResults\">$Next</a><p>\n";
}
Any thoughts?
-------------------------------------------------
This mail sent through IMP: http://horde.org/imp/
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php