如何在數據庫mysql中插入隨機值?如何在數據庫mysql中插入隨機值?
好吧,當我加載此代碼,我將有一個像這樣
5,3,1,6,4,
隨機數字格式,我想插入5,3,1,6, 4,進入數據庫mysql(1行1列),我該怎麼辦?
<?
$cards = array();
for ($i = 0; $i < 5; $i++)
{
$card = mt_rand(1, 6);
if(!in_array($card, $cards))
{
$cards[$i] = $card;
}
else
{
$i--;
}
}
foreach ($cards as $cards)
{
echo $cards.",";
}
?>
不工作,當我用你的代碼,它會被插入僅第一數到MySQL(不是所有數據) – user3141230