random image generator
i know how to make the random quote generator, but how do i make a random image generator, i figure it is the same set up in PHP code but how do you upload them to the mysql database and link them all right?
Thanks in advance
You might want to to store the filename of each image in a MySQL database, then use sql to get a random image Like this:
$selectimg = "SELECT * FROM images ORDER BY RAND() LIMIT 1";
$selectimgquery = mysql_query($selectimg);
$selimg = mysql_fetch_array($selectimgquery)
echo "<a href=\"page.html\"><img alt=\"$selimg[filename]\" src=\"images/graphics/thumbs/$selimg[filename]\"></a>"
$image_dir = './'; # customize
$images = glob($image_dir.'*.jpg');
echo '<img src="'.basename($images).'" alt="random image">';
ok well i just wanna use a path then from the database, but how do i put the path in the database and make it work with the right php code?
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)