I'm having some trouble. In the following code I'm trying to do something very simple, but the way I'm doing it causes the page to load TERRIBLY slowly.
What I'm doing is loading a list of names from a table in the database, and populating 10 drop down menus, on a form, with all of the names. (The drop down menus are for submitting attendance for clinics, hence the reason for 10 of them).
The problem is, the way I'm doing this right now (the only way I've been able to get it to work), is that I have to call the data from the table 10 different times (1 time for each of the 10 drop down menus in the form). Once the names are selected, the individual presses "SUBMIT" and the names are all added to the attendance table.
Is there any way to make this code more efficient? Or is this the only way of doing it?
Any help would be GREATLY appreciated.
<?
//set up table and database names
require($_SERVER['DOCUMENT_ROOT'] . '/include/reflist.php');
//build and issue query
$sql = "SELECT reg_id, reg_l_name, reg_f_name, reg_m_name, trim(concat(reg_l_name, ', ', reg_f_name, ' ' ,reg_m_name)) as referee_name, reg_city
FROM $table_name ORDER BY reg_l_name";
$result1 = @mysql_query($sql,$connection) or die(mysql_error());
$result2 = @mysql_query($sql,$connection) or die(mysql_error());
$result3 = @mysql_query($sql,$connection) or die(mysql_error());
$result4 = @mysql_query($sql,$connection) or die(mysql_error());
$result5 = @mysql_query($sql,$connection) or die(mysql_error());
$result6 = @mysql_query($sql,$connection) or die(mysql_error());
$result7 = @mysql_query($sql,$connection) or die(mysql_error());
$result8 = @mysql_query($sql,$connection) or die(mysql_error());
$result9 = @mysql_query($sql,$connection) or die(mysql_error());
$result10 = @mysql_query($sql,$connection) or die(mysql_error());
?>
Later on, the actual drop down menus are populated with this code (each of the 10 looks the same except they have different names, etc to keep them separated):
<select name="ca_referee1" id="ca_referee1" onFocus=populate(event) onKeyDown=setSelection(event) onKeyPress="javascript:return false">
<option selected></option>
<?
// put data into drop-down list box
while ($row = mysql_fetch_array($result1)) {
$ref_name1 = $row["referee_name"];
$ref_city1 = $row["reg_city"];
$ref_id1 = $row["reg_id"];
echo "<OPTION value=\"$ref_id1\">$ref_name1 - $ref_city1</OPTION>";
}
?>
</select>