从查询然后随机gen的数组。数组 [英] array from query then random gen. of array

查看:71
本文介绍了从查询然后随机gen的数组。数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从查询中创建一个数组,然后从数组中随机选择10个值,但我不断得到的错误是它不是作为数组读取的。提前感谢任何可以提供帮助的人。


$ query =" SELECT Id FROM January WHERE Username =''0''和Day =''1''" ;; < br $>
$ result = mysql_query($ query);


while($ row = mysql_fetch_assoc($ result))

{

echo $ row [''Id''];

echo"< br>" ;;

}


$ random = array_rand($ row);

echo $随机;

}

?>

I''m trying to make an array from a query and then randomly select 10 values from the array, but the error i keep getting is that it''s not reading as an array. Thanks in advance for anyone who can help.

$query = "SELECT Id FROM January WHERE Username=''0'' AND Day=''1''";
$result = mysql_query($query);

while($row=mysql_fetch_assoc($result))
{
echo $row[''Id''];
echo "<br>";
}

for($i=1; $i<=10; $i++){
$random = array_rand($row);
echo $random;
}
?>

推荐答案

query =" SELECT Id FROM January WHERE Username = ''0''日=''1''" ;;
query = "SELECT Id FROM January WHERE Username=''0'' AND Day=''1''";


result = mysql_query(
result = mysql_query(


query);


while(
query);

while(


这篇关于从查询然后随机gen的数组。数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆