I have a stockid field in my DB. In that are random numbers now that I have deleted and added stock. From the stockid's remaining, I would like to randomly choose 5 to be displayed.
Here is my current code:
<?
include('dbinfo.inc.php');
$query="SELECT * FROM auto ORDER BY stockid DESC LIMIT 5";
$result=mysql_query($query);
$num=5;
$i=0;
while ($i < $num) {
$stockid=mysql_result($result,$i,"stockid");
echo "<center>";
$listquery = mysql_query("SELECT * FROM auto WHERE stockid='$stockid'");
$row = mysql_fetch_assoc($listquery);
$stockid = $row['stockid'];
$year = $row['year'];
$make = $row['make'];
$model = $row['model'];
echo "<a href='show.php?stockid=$stockid'> $year $make $model </a> <br>";
++$i;
}
?></center>
Thanks!