Two questions about the following code. First Array problems.
I fill a select box from the database, but only the reg_name is showing up in the box. Am I storing or calling these wrong? Also how do I get the second cbostate listbox to come up from the choice selected on the first box? Is submit the wrong option?
FORM METHOD="LINK" ACTION="1.php">
<b>
<h2>Economic Indicators</h2>
</b>
<p align="left">Please select the regional unit of your interest: <br>
<select name="cboregion[$reg_id, $reg_name]" size="6" multiple class="listbox">
<?php
/
Create your SQL statement
/
$sql="SELECT reg_id, reg_name from tbl_regions;";
$result_set = pg_Exec ($conn, $sql);
$rows = pg_NumRows($result_set);
if ((!$result_set) || ($rows < 1)) {
//No connection or no rows returned, so print an error
echo "<H1>ERROR - no rows returned</H1><P>";
exit; //exit the script
}
for ($j=0; $j < $rows; $j++) {
echo "<option value=".pg_result($result_set, $j, "reg_id")."> ".pg_result($result_set, $j, "reg_name")."</option>";
}
?>
</select>
<? $reg_ch=$_GET['cboregion']; ?>
<? if(isset($_POST['reg_ch'])==2) { ?>
<p align="left">Please select the States of your interest: <br>
<select name="cbostate" size="auto" multiple class="listbox">
<?php
/
Create your SQL statement
/
$sql="SELECT fip_code, fip_name from tbl_fip_codes WHERE area_id =2;";
$result_set = pg_Exec ($conn, $sql);
$rows = pg_NumRows($result_set);
if ((!$result_set) || ($rows < 1)) {
//No connection or no rows returned, so print an error
echo "<H1>ERROR - no rows returned</H1><P>";
exit; //exit the script
}
for ($j=0; $j < $rows; $j++) {
echo "<option value=".pg_result($result_set, $j, "fip_code")."> ".pg_result($result_set, $j, "fip_name")."</option>";
} }
?>
</select>
<p align="left">
</FORM>
</body>
</html>