ok, see my problem is I have the following database table
---id---img---thumb---descript---
1 1.jpg 1.jpg my dog pat
2 2.jpg 2.jpg my new porsche
3 3.jpg 3.jpg Dads new house
Its an image gallery and anyhow I have a script that grabs a random image based on the amount of entries in the database.
$result = mysql_query( "SELECT * FROM photo_gallery" );
$num_rows = mysql_num_rows( $result );
The above gives me the amount of rows......now if I am never going to remove/edit images/entries then all is well.
My script then does this
srand ((double) microtime() * 1000000);
$a = rand(1,$num_rows);
print "<br><a href='gallery/index.php?id=$a&thumb=1' style='text-decoration: none'><img border=0 src = 'gallery/thumbs/$a.jpg'> </a>";
However say I remove entry #2 in my database then it will look like this:
---id---img---thumb---descript---
1 1.jpg 1.jpg my dog pat
3 3.jpg 3.jpg Dads new house
So the above script will try and grab entry 2 -- however it now does not exist. I hope this is understandable ... LOL!!! Anyone got some ideas for a work around?
Thanks for all your help people!!!