Note that there are some explanatory texts on larger screens.

plurals
  1. POI have a php error and will this code perform what I want it to do once I get it working?
    text
    copied!<p>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.</p> <p>Problem is I have an error in my code. Below is the code:</p> <pre><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 .= '&lt;select name="buildings" id="buildingssDrop"&gt;'.PHP_EOL; $buildingHTML .= '&lt;option value=""&gt;Please Select&lt;/option&gt;'.PHP_EOL; foreach ($sqldataArray as $building =&gt; $buildingData) { $buildingHTML .= "&lt;option value='".$building"'&gt;" . $building . "&lt;/option&gt;".PHP_EOL; } $buildingHTML .= '&lt;/select&gt;'; $roomHTML = ""; $roomHTML .= '&lt;select name="rooms" id="roomsDrop"&gt;'.PHP_EOL; $roomHTML .= '&lt;option value=""&gt;Please Select&lt;/option&gt;'.PHP_EOL; foreach ($buildingData['Rooms'] as $roomId =&gt; $roomData) { $roomHTML .= "&lt;option value='".$roomId"'&gt;" . $roomId . "&lt;/option&gt;".PHP_EOL; } $roomHTML .= '&lt;/select&gt;'; </code></pre> <p>The error I am getting is this:</p> <p>Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in /web/stud/u0867587/Mobile_app/create_session.php on line 363</p> <p>This is the line of code where the error is:</p> <pre><code> $buildingHTML .= "&lt;option value='".$building"'&gt;" . $building . "&lt;/option&gt;".PHP_EOL; </code></pre> <p>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?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload