What I want to do is display three random images from a database.
I want to use 'SELECT * FROM banner_images ORDER BY RAND() LIMIT 3', and at the end of the script, have three vars with the path (DB column) of the random images.
My Database Structure:
id name path
1 Banner-101 Banner-101.png
2 Banner-102 Banner-102.png
3 Banner-103 Banner-103.png
4 Banner-104 Banner-104.png
5 Banner-105 Banner-105.png
So for example after the script runs these are the vars
$path1 = 'Banner-103.png';
$path2 = 'Banner-105.png';
$path2 = 'Banner-101.png';
or something like that.
Does anyone know how I can do this?
Loop the rows and add to an array:
If you need those vairable names just assign them after:
Now you can just echo those 3 variable names like you wanted.