我在按下提交按钮时尝试创建PHP shuffle。我没有看到任何像我正在尝试做的例子,因为我将把输出的结果用于其他事情。截至目前,此代码已被破解,我无法通过此行的解析错误Parse error: syntax error, unexpected ')'
...
foreach ($shuffle_row) {
我的方法有什么问题?
$con = mysqli_connect("localhost", "ROOT", "", "DB");
$shuffle_run = mysqli_query($con,"SELECT * FROM users WHERE `group`= 3");
if( $shuffle_numrows > 0) {
while($shuffle_row = mysqli_fetch_assoc($shuffle_run)){
$shuffle_id = $shuffle_row['id'];
$shuffle_firstname = $suffle_row['firstname'];
$shuffle_lastname = $shuffle_row['lastname'];
$shuffle_username = $shuffle_row['username'];
$shuffle_email = $shuffle_row['email'];
if ($shuffle_firstname == true) {
echo $shuffle_firstname . $shuffle_lastname;
} else {
echo "No users have been registered yet.";
};
}
}
if(isset($_POST['shuffle'])) {
$shuffle_row = array();
shuffle($shuffle_row);
foreach ($shuffle_row) {
echo $shuffle_firstname . " " . $shuffle_lastname;
}
}
}
?>
<input type="submit" value="Shuffle" name="shuffle">