2013-10-09 65 views
0

在PHP選擇從MySQL數據庫填充填充下拉菜單如何獲得價值?

//function for dropdown 

function getDropDown($name, $table, $code, $desc) 
{ 
    $query = "SELECT $code, $desc FROM $table"; 
    echo "<select name=\"$name\">"; 
    echo '<option> Select One </option>'; 
    connect(); //connects to mysql 
    $result = mysql_query($query);`enter code here` 
    if(!$result) die ("error" . mysql_error()); 
    $foundRows = mysql_numrows ($result); 
    //loop to populate dropdown 
    for($row = 0; $row < $foundRows; ++$row) 
    { 
    list($c, $d) = mysql_fetch_row($result); 
    echo "<option name= value=\"$c\">$d</option>"; 
    } 
    echo "</select>"; 
} 

要使用選擇如何獲得價值?

+0

請澄清...你是什麼意思的「得到價值,如果sekected」?你是否想在表單提交之後設置'