0

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">    
the_pete
  • 822
  • 7
  • 19
Paul
  • 3,348
  • 5
  • 32
  • 76
  • I have errors in my question...how is it a duplicate?? – Paul Jul 15 '15 at 19:34
  • I took that out. See my comment below. In my text editor I forgot to delete some funky things. – Paul Jul 15 '15 at 19:38
  • You set `$shuffle_row` at the top of your code and then reset it with `$shuffle_row = array()`? – the_pete Jul 15 '15 at 19:51
  • You still also have a floating semicolon in your code `};` after your `else{...}` statement. – the_pete Jul 15 '15 at 19:52
  • I wasn't sure how else to generate the array. I'm pretty new to php – Paul Jul 15 '15 at 19:57
  • I cleaned up your code and noticed that you have an extra `}` at the end as well as the extra semicolon after the close parenthesis: `};` which you should remove. Try fixing those issues and run your code again. – the_pete Jul 15 '15 at 20:09
  • I took out the semi colon at the end of this ... `echo "No users have been registered yet."; };` and the same error is still showing. – Paul Jul 15 '15 at 20:12

0 Answers0