Jump to content

Image Rotator


Stegs

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.

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.