Hi
I've searched the posts for a solution as I know this has to be a common problem, but I've not found what I need.
I have created a multi-dimensional array in PHP from a MySQL database. I have a PHP form which creates a drop-down list of the names stored in the array. On selection, the value selected is passed to a javascript function before allowing the user to make additional selections. However, all that is returned is Array[2] (the name is stored as the second element of the array).
The JS function is
function reload_first(form)
{
//relaod the page using the data selected from the first drop-down box
var site_val=form.site_sel.options[form.site_sel.options.selectedIndex].value;
var screen_width = screen.width;
self.location='site_sel.php?site_sel='+site_val+'&width='+screen_width;
}
The PHP code is
echo "<form method=post>";
echo "<table class = 't2'>";
echo "<tr><td class = 't21' colspan = '3'>Site Information Selection</td></tr>";
echo "<tr align = 'center'>";
echo "<td class = 't21' rowspan = '2'><img src = 'Images/historic.jpg' alt = 'Historic data' height = '100' width = '100'><br />Historic Data</td>";
// Start drop down list
//populate with values from the site list
echo "<td class = 't21' colspan = '2'><img src = 'Images/sites.jpg' alt = 'Sites logo' width = '75' height = '75'/><br />Select the site<br />";
echo "<select name='site_sel' onchange=\"reload_first(this.form)\"><option value=''>Site...</option>";
$entry = 0;
$name_pos = 2;
while($entity_names[$entry][$name_pos]!= NULL)
{
if($entity_names[$entry][$name_pos] == @$site_id)
{
echo "<option selected value='$entity_names[$entry][$name_pos]'>$entity_names[$entry][$name_pos]</option>"."<br />";
}
else
{
echo "<option value = '$entity_names[$entry][$name_pos]'>" .$entity_names[$entry][$name_pos]."</option>";
}
$entry++;
}
echo "</select><br />";
echo "</div>";
echo "</td>";
As I siad, I know this has to be a common problem - but I can't find the solution. I can do it using a one-dimensional array, but not a multi-dimensional one.
Can anyone help?