What would be the most efficent way to access 4 random entries from a mySQL database and pull all information from them?
Right now im pulling all elements from the database into an array using mysql_fetch_array() then getting the sizeof() that array.
Then I was going to get 3 random numbers using the size of the array as the range.
This would be great if I could then get the elements from the array by index but is this possible to do without using a while statment on the result of the mysql_fetch_array() ?
$linkId = dbfconnect();
$SQL = "SELECT idNum, title FROM `listings` where catagory = '$catagory'";
$result = mysql_query($SQL);
$featureArray = mysql_fetch_array($result);
$range = $featureArray.sizeof();
$item1 = mt_rand (0, $range);
$item2 = mt_rand (0, $range);
$item3 = mt_rand (0, $range);
$item4 = mt_rand (0, $range);
Here's where im stuck. How can I take these random numbers and exstract all the information about a specific entry from $featureArray?
Would it be like this?
print($featureArray["$item1"]["title"]);
TIA
Jesse