duancao2082 2019-03-23 17:06
浏览 40

在数组中混洗变量以随机输出字符串

I created a form containing 4 boxes, if all 4 boxes have been filled the outputs are expected to shuffle into 4 groups. I have tried to used the array_rand() function but it will only randomise the output as instructed.

So i need it to shuffle without me knowing the sequence, which i tried to do but its not working as the database did not output the data.

How do i make it sync with the database? How do i make it work?

$a = array("$name1", "$name2", "$name3", "$name4");
shuffle($a);

$teamA = $a[0];
$teamB = $a[1];
$teamC = $a[2];
$teamD = $a[3];

$sql="INSERT INTO `teams`( `team_a`, `team_b`, `team_c`, `team_d`) VALUES ('$teamA','$teamB','$teamC','$teamD')";

$store= mysqli_query($conn,$sql);
if($store){
    echo'Registration Sucessful';
}else{
    echo'Not sucessful';
}
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 关于用pyqt6的项目开发该怎么把前段后端和业务层分离
    • ¥30 线性代数的问题,我真的忘了线代的知识了
    • ¥15 有谁能够把华为matebook e 高通骁龙850刷成安卓系统,或者安装安卓系统
    • ¥188 需要修改一个工具,懂得汇编的人来。
    • ¥15 livecharts wpf piechart 属性
    • ¥20 数学建模,尽量用matlab回答,论文格式
    • ¥15 昨天挂载了一下u盘,然后拔了
    • ¥30 win from 窗口最大最小化,控件放大缩小,闪烁问题
    • ¥20 易康econgnition精度验证
    • ¥15 msix packaging tool打包问题