我对 PHP 很陌生,我有一个测试项目:
我想让代码更高效,因为它需要一些时间来生成。非常感谢,纳特
它使用的代码如下:
$result1 = mysql_fetch_assoc(mysql_query("SELECT COUNT(*) AS `Rows`, `1` FROM `things` GROUP BY `1` ORDER BY RAND() LIMIT 0 , 1"));
$result2 = mysql_fetch_assoc(mysql_query("SELECT COUNT(*) AS `Rows`, `2` FROM `things` GROUP BY `2` ORDER BY RAND() LIMIT 0 , 1"));
$result3 = mysql_fetch_assoc(mysql_query("SELECT COUNT(*) AS `Rows`, `3` FROM `things` GROUP BY `3` ORDER BY RAND() LIMIT 0 , 1"));
$result4 = mysql_fetch_assoc(mysql_query("SELECT COUNT(*) AS `Rows`, `4` FROM `things` GROUP BY `4` ORDER BY RAND() LIMIT 0 , 1"));
echo $result1["1"];
echo " ";
echo $result2["2"];
echo " ";
echo $result3["3"];
echo " ";
echo $result4["4"];
mysql_close($con);
?>