I'm attempting to create a PHP shuffle when a submit button is pressed. I have not seen any examples like what I am trying to do as I am going to be using the outputted results for other things. As of right now this code is broken and I cannot get past a parse error Parse error: syntax error, unexpected ')'
for this line...
foreach ($shuffle_row) {
What am I doing wrong in my approach?
$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">