function getLink(&$count, $ids, &$id) { global $db, $link_t; $db->query("select min(id) minID, max(id) maxID, count(id) maxCount from {$link_t} where visible=1"); $db->next_record(); $min = $db->f('minID'); $max = $db->f('maxID'); $maxCount = $db->f('maxCount'); if (!$min || !$max) { return ""; } //可能没有记录 if ($count > $maxCount) { $count = $maxCount; } do { if ($min == $max) { $id = $min; } else { do { srand((double) microtime() * 1000000); $id = rand($min, $max); } while (in_array($id, $ids)); } $db->query("select id,name,url,width,height from {$link_t} where id={$id} and visible=1"); $db->next_record(); if ($db->num_rows()) { $result = getALink($link); } } while (!$db->num_rows()); return $result; }
echo $http_head; ?> <link rel="stylesheet" href="conf/style.css" type="text/css"> </head> <body bgcolor="#FFFFFF" text="#000000"> <?php include "conf/header.php"; $db->query("select id,name,url,width,height from {$link_t} where visible=1 order by id desc"); echo "<p></p>"; echo "<table width=500 align=center border=0 cellspacing=0 cellpadding=10>\n"; $i = 0; while ($db->next_record()) { if ($i % 2 == 0) { echo "<tr>\n"; } echo "<td align=center width=120>" . getALink($link) . "</td>\n"; echo "<td><a href=\"link.php?id=" . $db->f('id') . "&url=" . $db->f('url') . "\" target=\"_blank\" class=\"clink03\">" . $db->f('name') . "</a><br>" . $db->f('url') . "</td>\n"; if ($i % 2 == 0) { echo "<td width=20%></td>\n"; } if ($i % 2 == 1) { echo "</tr>\n"; } $i++; } if ($i % 2 == 1) { echo "<td></td><td></td></tr>\n"; } echo "</table>\n"; ?> <p> </p>