Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 02-25-2007, 07:21 PM   PM User | #1
husnamina
New Coder

 
Join Date: Jul 2006
Posts: 63
Thanks: 0
Thanked 0 Times in 0 Posts
husnamina is an unknown quantity at this point
a selection in a list to populate another list on the same form

Hi there every one,
Please i have a form with 3 dropdown list.
the first is for a canditate, 2nd is for party, 3rd is for state and 4th is for the local areas in the state.
I want if the user selects a state, the dropdown list for the local area to be populated automatically.
But since they are on the same form i am not sure how.here is my code
PHP Code:
    <td><select name="state" tabindex="3">
                 <?php #this is to get listing for roles in a drop dowm menu 
                       #the sql query
                          
$sql1 "SELECT distinct(state_name) FROM state order by state_name ";
                      
#execute query
                          
$rs1 mysql_query($sql1$myConn) or die ("could not execute query $sql");
          
                      if (
$rs1){  
                              while (
$row1 mysql_fetch_array ($rs1)){
                                           echo(
"<option>" $row1['state_name'] . "</option>"); 
                                       }
                          }
                       else{
                                  echo 
"<option> No states have been registered - Add Please </option>";
                           }
                           
                       
mysql_free_result($rs);
    

                
?>
        </select></td>
    </tr>
    <?php $stid$row1['state_name']; ?>* here is what i thot of 
    <tr>
        <td> <label> Select Local Goverment </label></td>
        <td><select name="localgov" tabindex="4">
                 <?php 
                         $sql2 
"SELECT distinct(name) FROM lg order by name where state_id=(select state_id from state where state_name=\"$stid\")";
                      
#execute query
                          
$rs2 mysql_query($sql2$myConn) or die ("could not execute query $sql");
          
                      if (
$rs2){  
                              while (
$row2 mysql_fetch_array ($rs2)){
                                           echo(
"<option>" $row2['name'] . "</option>"); 
                                       }
                          }
                       else{
                                  echo 
"<option> No local governemnts have been registered - Add Please </option>";
                           }
                           
                       
mysql_free_result($rs);
    

                
?>
        </select></td>
    </tr>
Thank you.
husnamina is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 06:52 PM.


Advertisement
Log in to turn off these ads.