here's one way (not tested). this is a bit more optimzed that your orginal since it does fewer hits to the database:
$size = 15038;
$sql = "SELECT * FROM banners WHERE Bannersize = '$size' order by rand() limit 6";
$result = mysql_query ($sql);
if (mysql_num_rows ($result))
{
while ($row = mysql_fetch_assoc ($result))
{
$banner_array[$row['Username']] = $row;
}
}
$result = mysql_query ('SELECT Username, Webaddress FROM website WHERE Username IN(' . implode (',', array_keys ($banner_array)) . ')');
while ($row = mysql_fetch_assoc ($result))
{
$banner_array[$row['Username']]['Webaddress'] = $row['Webaddress'];
}
sort ($banner_array);
$top_row = array_slice ($banner_array, 0, 3);
$bottom_row = array_slice ($banner_array, 3, 3);
echo '<table border=1><tr>';
foreach ($top_row as $key => $value)
{
echo '<td>' . $value['Bannername'] . '</td>';
}
echo '</tr><tr>';
foreach ($bottom_row as $key => $value)
{
echo '<td>' . $value['Bannername'] . '</td>';
}
echo '</tr></table>';