$result = $db->sql_query("SELECT bid, cid, imptotal, impmade, clicks, imageurl, date, type, active from " . $prefix . "_banner WHERE active='1' order by type,bid");
while ($row = $db->sql_fetchrow($result)) {
$bid = intval($row['bid']);
$cid = intval($row['cid']);
$imptotal = intval($row['imptotal']);
$impmade = intval($row['impmade']);
$clicks = intval($row['clicks']);
$imageurl = $row['imageurl'];
$date = $row['date'];
$type = $row['type'];
$active = intval($row['active']);
$row2 = $db->sql_fetchrow($db->sql_query("SELECT cid, name from " . $prefix . "_bannerclient where cid='$cid'"));
$result = $db->sql_query("SELECT bid, cid, imptotal, impmade, clicks, imageurl, date, type, active from " . $prefix . "_banner WHERE active='0' order by type,bid");
while ($row = $db->sql_fetchrow($result)) {
$bid = intval($row['bid']);
$cid = intval($row['cid']);
$imptotal = intval($row['imptotal']);
$impmade = intval($row['impmade']);
$clicks = intval($row['clicks']);
$imageurl = $row['imageurl'];
$date = $row['date'];
$type = $row['type'];
$active = intval($row['active']);
$row2 = $db->sql_fetchrow($db->sql_query("SELECT cid, name from " . $prefix . "_bannerclient where cid='$cid'"));