Hi i created the following function for a previous e-commerce site.
[code]$sql=”select MAX(productID) as prodID from Products”;
$result=mysql_query($sql) or die (“ERROR!! Unable to perform query!”);
$row=mysql_fetch_array($result);
$maxProdID=$row[‘prodID’];
$maxProdID–;
$id=(rand()%$maxProdID);
$id++;
What this is used for is to display a random image each time a user enters/refreshes the site. The field productID is an auto increment and a product was never deleted from the database which meant that an image was always displayed. However im creating a new site now which asks that when an item is sold its deleted from the products table which means a random number which is generated may not have a corresponding entry in the products table. So my question is is there a way to generate a random number from an array of possible entries i.e. get all the productID from the tables and generate a random numbers from just those values. Hope i made myself clear.