Jump to content

Archived

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

rajmohan

displaying a image?????? in random

Recommended Posts

I am having 10 images in one table now i want to display the image randomly......

that is

1

3
4
means after refreshing my page it should change like this


3
4
1
2

then shuffle if i refresh my page please help me

Share this post


Link to post
Share on other sites
Just use the shuffle function.

[code]
$array = Array("image1.jpg","image2.jpg","image3.jpg","image4.jpg","image5.jpg");
shuffle($array);
[/code]

Share this post


Link to post
Share on other sites
Just get the table rows into an array.

[code]
$sql    = "SELECT images_column FROM your_table";
$result = mysql_query($sql);
while($data = mysql_fetch_array($result))
$images_arr[] = $data["images_column"];
shuffle($images_arr);
[/code]

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.