Error on page

Hi. I have created a small form with a radio button, textbox and a list on it. When I click on the radio button I want the list to be populated with some records from a database. I do not know what is the problem with my code and I hope someone can help me. I AM VERY NEW WITH PHP.


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>

<?php 
require_once($_SERVER["DOCUMENT_ROOT"].'/ITA/DB/OpenDB.php');

function LoadBuildings(){
$strSQL = "SELECT internalCodeBuilding FROM building";
$result=mysql_query($strSQL) or die("Unable to select the information!");
echo'<select name="lstBuilding"><option value=""></option>';

while($rand=mysql_fetch_array($result)){
echo '<option value='.$rand['internalCodeBuilding'].'</option>';
}
echo'</select>';
}

echo '
<table width="80%" border="1">
  <tr>
    <td><p>
      <label>
        <input type="radio" name="RadioGroup1" value="building" id="RadioGroup1_0" onclick="LoadBuildings()";/>
        Building</label>
      <br />
    </p></td>
    <td>Building name: 
      <label>
      <input type="text" name="txtBuildingName" id="txtBuildingName" />
    </label></td>
    <td>Select building: 
      <label>
      <select name="lstBuilding" id="lstBuilding">
      </select>
    </label></td>
  </tr>
</table>
';
?>

</body>
</html>


Thank you.

Hi. How do I integrate JS in my code? Thx.

Firstly the onclick event is reserved for JS functions only, the only way you can get records is to either pre-load them on the page and add unique ID’s to them so you can append them to the list or use Ajax which would be better