0
i'm Having 3 tables those are like 1.State table 2. District Table 3.college Table
state table
cat_id       state
 1         Andhrapradesh    
 2          Gujarat
 3          Punjab
 4           mumbai
 ---------------
 district Table

 cat_id  d_id      district
  1       1        vizag   
  1       2        eastgadavari
  1       3        hyderabad
  1       4        westgadavari
  --------------------------------------
  college table 
 Cat_id  d_id  c_id   c_name
  1       1     1     vits
  1       1     2     geetham
  1       1     3     anits

  ---------------------------------
  now i want make a 3 dropdown lists from database dynamically.
  any 1 plz help me.
  all the three combo lists are dependent & They are in single Form.
  Thanks to Every1......
3
Contributors
2
Replies
7
Views
4 Years
Discussion Span
Last Post by david.leatherman.908
0

This can get you started - code for creating State Table - call from body where you want it - the input can be 0 to not select any of the choices or an index value of one of the choices to display pre-selected choice...

function StateDropDown($nSel)
{
    $pick;

    global $db;

    $ret_string = "<select name='StateDropDown'><option value='0'>Select State</option>";

    $query = 'SELECT cat_id, state FROM StateTable';
    $result = mysql_query($query, $db) or die(mysql_error($db));
    while ($rows = mysql_fetch_array($result)) 
    {
    $CAT_ID  = $rows[0];
    $ST_Name = $rows[1];
    if ($nSel == $CAT_ID)
        $pick = " SELECTED ";
    else
        $pick = "";

    $ret_string = $ret_string . "<option value='" . $CAT_ID . "'" . $pick . ">" . $ST_Name . "</option>";
    }
$ret_string = $ret_string . "</select>";
return $ret_string;
}

By using the index of the returned selection, you can similarly fashion (dynamically) the next drop down.

Hope it helps

Edited by david.leatherman.908

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.