You have to use recursive functions for this. You can write one..
function linkchecker($id)
{
$query="SELECT COUNT(*) AS mycount FROM tablename WHERE id=".$id."";
$result=mysql_query($query);
$row=mysql_fetch_array($result);
$nextid = $id + 1;
if (($row["mycount"]) > 0 )
{
echo "<a href=link.php?id=\"".$nextid."\"> link </a>";
}
else
{
linkchecker($nextid);
}
}
Modify this to your needs..
I hope this helps..
Gurhan
On Thu, 2002-09-05 at 17:20, tux wrote:
>
> hey all,
>
> if im displaying pages with data from a database eg
>
> www.domain.com/file.php?id=40
>
> on that page i would like to have a previous and next link that would
> take it to id 41 and 39 respectively, the only problem being what if 39
> or 41 was empty? then i would want the link to be id=42 or id=38.. is
> the best way to do this just loop through the id's until it finds a
> entry that isnt empty? or is there any functions for this?
>
> jo
>
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php