Stegs Posted September 14, 2006 Share Posted September 14, 2006 My head is spinning with all the image rotating codes I have seen on various sites, yet none seem to do what I am looking for.I am looking for something like here (found it through another msg board on coding issues) http://www.chickenbucket.com/e107/page.php?7Where on a sidebar they have a random thumbnail. When a visitor wants to see it bigger they can click on it and it will take them to a bigger view (they use a gallery, I dont want/need a gallery style...just an image)It is the last part I need to figure out before I can move from test to implementation (hopefully)http://laxnation.com/home/testindex.phpSo basically I want a random thumbnail to show up with a link to something like http: //laxnation.com/home/displaypic.php?picid=14thumbnail 14 links to full image 14, thumbnail 1 links to full image 1. Link to comment https://forums.phpfreaks.com/topic/20680-image-rotator/ Share on other sites More sharing options...
skatermike21988 Posted September 14, 2006 Share Posted September 14, 2006 This worked for me. It will display a random pic everytime the page is refreshed[code]$sql = mysql_query("SELECTphoto_id FROM photos ORDER BY rand() LIMIT 1") or die (mysql_error()); while($info = mysql_fetch_array( $sql )) { $photo_id=$info['photo_id'];$data = mysql_query("SELECT * FROM photos WHERE photo_id='$photo_id'") or die(mysql_error()); while($info = mysql_fetch_array( $data )) { $photo_source=$info['photo_source'];Print "<td><a href='http://www.yoursite.com/displaypic?picid=$photo_id"; Print "&sid=$sid' target='_self'>";Print "<img src='$photo_source' height='75' width='75'>"; }}[/code]It pulls a random photo id from the database and then performs a query on that id pulling out the image source and displays a link with that id.Hope this helps**MODIFIED THIS CODE HAVE NOT TESTED** SHOULD WORK FINE THOUGH Link to comment https://forums.phpfreaks.com/topic/20680-image-rotator/#findComment-91540 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.