I have two php routines in a web page. Both are alike except variables. Both will output the HTML <options> for <select> in both routines. Have verified the source at the browser for both. But the first one is not displaying.
The correct HTML code is in the browser and have saved it as a htm file. Running this file, the web page does display correctly, with the proper 'selected' option.
first one not working:
Expand|Select|Wrap|Line Numbers
- <tr>
- <td align="left">State/Province
- <span id="star">*</span>
- </td>
- <td align="left">
- <div id="shipping_to_state_div" style="float:left">
- <select id="shipping_to_state_prov" name="shipping_to_state_prov">
- <?php
- $sql = "SELECT * FROM state WHERE country='".$country."'";
- $data_assoc_array = $db->getQuery($sql);
- $data_num_rows = $db->num_rows;
- echo '<option value="">Select State_Prov</option>';
- for( $indx = 0; $indx < $data_num_rows; $indx++ )
- {
- echo '<option value="'.$data_assoc_array[$indx]['ID'].'"';
- if( $data_assoc_array[$indx]['ID'] == $shipping_to_state_prov )
- {
- echo ' selected';
- }
- echo ' >'. $data_assoc_array[$indx]['title']. '</OPTION>'."\n";
- }
- ?>
- </SELECT>
- </div>
- </td>
- </tr>
Expand|Select|Wrap|Line Numbers
- <tr>
- <td align="left">State/Province
- <span id="star">*</span>
- </td>
- <td align="left">
- <div id="shipping_to_state_div" style="float:left">
- <select id="shipping_to_state_prov" name="shipping_to_state_prov">
- <?php
- $sql = "SELECT * FROM state WHERE country='".$country."'";
- $data_assoc_array = $db->getQuery($sql);
- $data_num_rows = $db->num_rows;
- echo '<option value="">Select State_Prov</option>';
- for( $indx = 0; $indx < $data_num_rows; $indx++ )
- {
- echo '<option value="'.$data_assoc_array[$indx]['ID'].'"';
- if( $data_assoc_array[$indx]['ID'] == $shipping_to_state_prov )
- {
- echo ' selected';
- }
- echo ' >'. $data_assoc_array[$indx]['title']. '</OPTION>'."\n";
- }
- ?>
- </SELECT>
- </div>
- </td>
- </tr>