<?php 
include 'db.php';  

$data = mysql_query("SELECT * FROM `rek` WHERE `ok` = '1' AND `srok` = '1' ORDER BY RAND() LIMIT 5");

while ($row = mysql_fetch_assoc($data)){  

echo '<a href="'.$row['url'].'" rel="nofollow" style="color:'.$row['color'].'">'.$row['name'].'</a><br/>';   
} 
echo '  
<div class="rek"><a href="pay/index.php" rel="nofollow">Покупка рекламы</a><br/></div>'; 
?> 