0

Hello Im trying to display all my rooms from database in my select form like this:

    $calendar.= "<br>
<form id ='room_select_form'>
<div class ='row'>
    <div class = 'col-md-6 col-md-offset-3 form-group'>
        <label>Select Room</label>
        <select class = 'form-control' id = 'room_select'>".$rooms."</select>
    </div>
</div>
</form>";

And here is my code how to get my rooms from the datebase, i only got 4 rooms:

    $query = $con->prepare('SELECT * FROM rooms');
$rooms = "";
if($query->execute()){
    $result = $query->get_result();
    if($result->num_rows>0){
        while($row = $result->fetch_assoc()){
            $rooms. = "<option value = '".$row['id']."'>".$row['name']."</option>";
        }
        $query->close();
    }
}

So my problem is I only get rooms 4 when i make $rooms without . in the end and when I got the . the whole page is white, i get error on that line

PHP Parse error: syntax error, unexpected '='

What Am I doing wrong?:(

Nigel Ren
  • 56,122
  • 11
  • 43
  • 55

1 Answers1

2

It should be .= not . =

$rooms .= "<option value = '".$row['id']."'>".$row['name']."</option>";
fraggley
  • 1,215
  • 2
  • 9
  • 19
  • wow didn't know there was a difference need to check that up, thanks alot:) –  May 17 '20 at 09:35