你能告诉我如何把这个查询放在表中..
<?
$username="root";
$password="kermit";
$database="moodle";
mysql_connect(localhost,$username,$password);
mysql_select_db($database) or die( "Unable to select database");
$query = "SELECT user.firstname, user.lastname, stats.userid, stats.roleid, SUM( statsreads ) AS numreads, SUM( statswrites ) AS numwrites, SUM( statsreads ) + SUM( statswrites ) AS totalactivity FROM `mdl_stats_user_daily` stats, `mdl_user` user WHERE userid IN (SELECT userid FROM mdl_role_assignments WHERE roleid IN (1,2,3,4)) AND user.id = stats.userid AND stats.timeend > ".(time() - 604800)." GROUP BY userid ORDER BY totalactivity DESC";
result=mysql_query($query);
$num_rows = mysql_num_rows($result);
mysql_close();
谢谢 :)