...

View Full Version : Display Random



simjay
08-27-2005, 11:22 PM
Here is my code, i need it to display 1 entry from the database randomly? And ideas. As you can tell im a newbie


<?php
$sql = "SELECT * FROM banner";
$result = mysql_query($sql, $conn) or die(mysql_error());
while ($newArray = mysql_fetch_array($result)) {
$banner_id = $newArray['banner_id'];
$banner_dir = $newArray['banner_dir'];
$banner_bussiness = $newArray['banner_bussiness'];
$banner_website = $newArray['banner_website'];
echo "<a href='$banner_website'><img src='banner/$banner_dir' alt='$banner_bussiness' border='0' height='60px' width='468px'></a> ";
}
?>

marek_mar
08-27-2005, 11:35 PM
SELECT * FROM foo ORDER BY RAND() LIMIT 1



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum