מתוך מערכת באנרים שאני בניתי:
PHP קוד:
<?php
include("connect.php");
$show = mysql_query("SELECT ID, image, alt FROM banners WHERE inout='1' order by ID") or die(mysql_error());
$rows = mysql_num_rows($show);
$randnum = rand(1,$rows);
$i = 1;
while ($res = mysql_fetch_array($show)) {
$banner{$i} = '<a href="http://www.domain.com/goto.php?id=' . $res['ID'] . '" target="_blank"><img src="' . $res['image'] . '"
alt="' . $res['alt'] . '" border="0" /></a>';
$i++;
}
$showbanner = $banner{$randnum};
?>