我正在尝试random
从数据库中获取记录mysql
,它可以工作,但是当我获取它们时我也需要记录,unique
因为它们在输出中重复,这是我的代码:
<?
for ($counter = 1; $counter <=5;$counter++)
{
$randomPostSelect = mysql_query("SELECT DISTINCT * FROM beventreservation WHERE (beventStatus='online' OR beventStatus='soldout') ORDER BY RAND() LIMIT 5") or die(mysql_error());
$fetchPosts = mysql_fetch_array($randomPostSelect) or die(mysql_error());
echo '<li><a href="reservation.php?rev='.$fetchPosts['eventId'].'">'.$fetchPosts['eventTitle'].'</a></li>';
echo '</br>';
}
?>
我怎样才能做到这一点 ?