Jump to content

Shuffle array taken from mysql


Baabu

Recommended Posts

<?php


mysql_connect("localhost","test","pass") or die ('Unable to Connect');
mysql_select_db("test")or die('Unable to select');;

$query="select * from images";
$result=mysql_query($query) or die ("Error in Query .".mysql_error());
shuffle($result);
while($row=mysql_fetch_array($result))
{
?>
<img src="<?php echo $row['path'];?>">
<?php
echo "<br>";
}
?>

well this code takes the path from mysql image table and then displays the image everything is working fine i just want to know how can i make these images to be random like they are displayed as in the order they are stored i want to change it each time mysql returns the paths in $result they should be shuffled?? any suggestions?

Link to comment
https://forums.phpfreaks.com/topic/93735-shuffle-array-taken-from-mysql/
Share on other sites

Archived

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

×
×
  • 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.