I have a little issue with my coding. I am trying to create 2 dropdown menus. One for displaying a list of buildings and then when user selects a building from the list, it will display the list of rooms in that building.
Problem is I have an error in my code. Below is the code:
$sql="SELECT Building, Room FROM Room WHERE Building = '".$building."'";
$sqlresult = mysql_query($sql);
$sqldataArray = array();
while($sqlrow = mysql_fetch_array($sqlresult))
{
$sqldataArray[$sqlrow['Building']];
$sqldataArray[$sqlrow['Building']]['Rooms'][$sqlrow['Room']];
}
$buildingHTML = "";
$buildingHTML .= '<select name="buildings" id="buildingssDrop">'.PHP_EOL;
$buildingHTML .= '<option value="">Please Select</option>'.PHP_EOL;
foreach ($sqldataArray as $building => $buildingData) {
$buildingHTML .= "<option value='".$building"'>" . $building . "</option>".PHP_EOL;
}
$buildingHTML .= '</select>';
$roomHTML = "";
$roomHTML .= '<select name="rooms" id="roomsDrop">'.PHP_EOL;
$roomHTML .= '<option value="">Please Select</option>'.PHP_EOL;
foreach ($buildingData['Rooms'] as $roomId => $roomData) {
$roomHTML .= "<option value='".$roomId"'>" . $roomId . "</option>".PHP_EOL;
}
$roomHTML .= '</select>';
The error I am getting is this:
Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in /web/stud/u0867587/Mobile_app/create_session.php on line 363
This is the line of code where the error is:
$buildingHTML .= "<option value='".$building"'>" . $building . "</option>".PHP_EOL;
Does anyone know how to fix this error and will this code I have written be able to perform what I said I want the dropdown menus to perform?
Change:
To:
and change:
To:
Using consistent spacing between the concatenation operations can help make these easier to spot in the future: