Jump to content


Photo

displaying a image?????? in random


  • Please log in to reply
3 replies to this topic

#1 rajmohan

rajmohan
  • Members
  • PipPipPip
  • Advanced Member
  • 169 posts

Posted 04 October 2006 - 09:26 AM

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


#2 ponsho

ponsho
  • Members
  • PipPip
  • Member
  • 24 posts

Posted 04 October 2006 - 09:34 AM

Just use the shuffle function.

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


#3 rajmohan

rajmohan
  • Members
  • PipPipPip
  • Advanced Member
  • 169 posts

Posted 04 October 2006 - 09:42 AM

the no. of images may be countless

Then

#4 ponsho

ponsho
  • Members
  • PipPip
  • Member
  • 24 posts

Posted 04 October 2006 - 09:46 AM

Just get the table rows into an array.

$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);





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users