0
$sql = "SELECT distinct s.doc_id, s.pat_id as pat_id, p.pat_fullname as fullname, p.pat_id from patient p, patientscript s WHERE s.doc_id = '$doc_id' AND s.status = '1' AND s.pat_id = p.pat_id;";
$result = mysql_query($sql) OR
    die("Database Error. MYSQL-Error:".mysql_error()."\n");
echo "<form name='form'> ";
echo "<label>Patient :</label>";
echo "<select name='patname'>";
echo "<option>Select a patient</option>";
while ($row = mysql_fetch_array($result))
{
    $patname = $row['fullname'];    
    $pat_id = $row['pat_id'];
    echo  "<option value='$patname'>$patname</option>"; 
}
echo "</select>";
echo "<input type='button' value='Submit' onClick='get();' >";
echo "<input type='hidden' name='pat_id' value='$pat_id'/>";
echo "</form>";
echo "<div id='showName'></div>";

Let say, there are 2 echo results from option value, A and B. When select A, I get 12(id) A from output When select B, I get 12(id) B from output Actually the 12 is for B, A是7,任何人都可以帮我解决这个问题。

4

1 回答 1

0

试试这个:

(...)

echo "<select name='patdata'>";
    echo "<option>Select a patient</option>";
    while ($row = mysql_fetch_array($result))
    {
        $patname = $row['fullname'];    
        $pat_id = $row['pat_id'];
        echo  "<option value='".$patname."-".$pat_id."'>$patname</option>"; 
    }
    echo "</select>";
    echo "<input type='button' value='Submit' onClick='get();' >";
    echo "</form>";

(...)

然后,(我假设您在发布后获取结果)

$patdata = explode( '-', $_REQUEST['patdata']);
$patname = $patdata[0];
$pat_id = $patdata[1];
于 2012-12-08T15:02:03.677 回答