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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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