Jump to content

Archived

This topic is now archived and is closed to further replies.

Stegs

Image Rotator

Recommended Posts

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?7
Where 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.php
So basically I want a random thumbnail to show up with a link to something like http: //laxnation.com/home/displaypic.php?picid=14
thumbnail 14 links to full image 14, thumbnail 1 links to full image 1.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.