mysql如下:"select
*
from
youtable
order
by
rand()
limit
5"
2)同样随机取5-10条:
$num=rand(5,10)
$sql="select
*
from
youtable
order
by
rand()
limit
$num"
ps:为什么不是php分类问题?
$sql = "select count(*) from table"$result = mysql_query($sql)
$row = mysql_fetch_array($result)
$MAX = $row["0"] //数据总条数
$rand = mt_rand(0,$$MAX) //随机数,0~$MAX
$per = 5//每组人数
$sql = "select * from table limit " . $rand . "," . $per . ""
$result = mysql_query($sql)
while ($row = mysql_fetch_array($result)) {
echo $row["0"]
echo $row["1"]
/* ~~~~~~~~~~~ */
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)