I'm trying to query a table and then place this into an array which can be used to update a drop-down form box though a JavaScript function:
// create the array for servers
$query = "SELECT name FROM server";
$result = mysql_query($query);
$num_results = mysql_num_rows($result);
$row = mysql_fetch_array($result);
$j = 1;
for ($i=0; $i<$num_results; $i++) {
echo "form.state.options[$j] = new Option(\"$row[$i]\", \"$j\");\n";
$j = $j + 1;
}
The problem is that only one record is being pulled through but there shuld be 3. However, the drop-down box provides an additional 2 spaces which are empty along with the only record that manages to get through. I can't see where I'm going wrong. Am I missing something obvious here? Thanks...
================================
"Chaos, panic & disorder - my work here is done!"
================================
// create the array for servers
$query = "SELECT name FROM server";
$result = mysql_query($query);
$num_results = mysql_num_rows($result);
$row = mysql_fetch_array($result);
$j = 1;
for ($i=0; $i<$num_results; $i++) {
echo "form.state.options[$j] = new Option(\"$row[$i]\", \"$j\");\n";
$j = $j + 1;
}
The problem is that only one record is being pulled through but there shuld be 3. However, the drop-down box provides an additional 2 spaces which are empty along with the only record that manages to get through. I can't see where I'm going wrong. Am I missing something obvious here? Thanks...
================================
"Chaos, panic & disorder - my work here is done!"
================================