what i want to do is to select a state then select a city based on the "state_id" and the result to be stored into the "city" field inside the "table" table.
the code will look like this:
Expand|Select|Wrap|Line Numbers
- $city = isset($_REQUEST['city']) ? addslashes($_REQUEST['city']) : 0;
- $state = isset($_REQUEST['state']) ? addslashes($_REQUEST['state']) : '';
- <table>
- <tr>
- <td>Search by Departure County
- <select name="state" id="state" onChange="return getCity(this.value);">
- <option value="">Select State</option>
- {section name=res loop=$resultS}
- <option value="{$resultS[res].id}" {if $state == $resultS[res].id} selected {/if}>{$resultS[res].state}</option>
- {/section}
- </select>
- </td>
- <td id="city_td">
- {if isset($cityC)}
- <select name="city" id="city" onchange='return getCityResult(this.value);'>
- <option value="">Select County</option>
- {section name=res loop=$cityC}
- <option value="{$cityC[res].id}" {if $city == $cityC[res].id} selected {/if}>{$cityC[res].city}</option>
- {/section}
- </select>
- {else}
- <select name="city" id="city">
- <option value="">Select County</option>
- </select>
- {/if}
- </td>
- </tr>
- </table>
Expand|Select|Wrap|Line Numbers
- /**State**/
- $sqlS = 'SELECT * FROM states ORDER BY state ASC';
- $qryResult = $db->query($sqlS);
- if(DB::isError($qryResult))
- {
- die($qryResult->getMessage());
- }
- $i = 0;
- $resultS = array();
- while($row = $qryResult->fetchRow(DB_FETCHMODE_ASSOC))
- {
- $tmp = array(
- 'id' => $row['id'],
- 'state' => $row['state']
- );
- $resultS[$i++] = $tmp;
- }
- //$smarty->assign('archive', 1);
- $smarty->assign('resultS', $resultS);
- //print_r($resultS);
- /**State**/
thanks a lot