CRON

$b=mysql_connect("localhost","root","") or die(mysql_error());
mysql_select_db("test",$b);

mysql_query("TRUNCATE TABLE top");
$toplamHesap=mysql_query("SELECT user_id FROM user");
$tophesap=mysql_num_rows($toplamHesap);

$q=mysql_query("SELECT user_id FROM user");
while ($w=mysql_fetch_array($q)) {
echo "Kullanici ID: " . $w['user_id'];
$hesap=$w['user_id'];
$q2=mysql_query("SELECT user_id FROM makicerik WHERE user_id=$hesap AND icerik_tarih >= curdate() - INTERVAL DAYOFWEEK(curdate())+6 DAY AND icerik_tarih < curdate() - INTERVAL DAYOFWEEK(curdate())-1 DAY");
echo " Toplam Yazi: " . mysql_num_rows($q2) ."
";
$icerik_sayi = mysql_num_rows($q2);

$q4=mysql_query("INSERT INTO top (user_id,icerik_sayi) VALUES ($hesap,$icerik_sayi)");
}
?>


YAZDIRMA

$q=mysql_query("SELECT * FROM top ORDER BY icerik_sayi DESC");
while($w=mysql_fetch_array($q)) {
$hesap=$w['user_id'];
$q3=mysql_query("SELECT user_id, user_name FROM user WHERE user_id LIKE '$hesap'");
while ($w3=mysql_fetch_array($q3)) {
echo $user_name = $w3['user_name'];
}
}