One thing that you could try is using the mtrand function, but the thing about that is the ids of each row in the db would have to be in order (1,2,3,...). The way that you could do the mtrand is
PHP Code:
<?php
include "db.php";
$query = "SELECT * FROM product where shopName = 'pure' ";
$info = mysql_query($query, $conn) or die(mysql_error());
$num = mysql_num_rows($info);
$image = mtrand(1,$num);
$sql ="select image from product where shopName = 'pure' and id='$image'";
$result = mysql_query($sql, $conn) or die(mysql_error());
if($result){
echo'
<table align="center" cellspacing="0" cellpadding="5" bgcolor="#ffffff" border=1 bordercolor="#2696b8">
<tr>
</tr>';
while($row = mysql_fetch_array($result, MYSQL_ASSOC)){
echo'<tr>
<td align="center" width="150" height="200"><img src="http://snet.wit.ie/~ciaracousins/clothes/' . $row['image'] . '">
</tr>';
}
echo'</table>';
}
else{
echo'<h1> System Error </h1> table ';
exit();
}
mysql_close();
?>
</html></body>
There may be other more complicated ways, but this is the way that I find the easiest.
Bookmarks