I need to get the list of diagnosed disease of the patient by choosing his name in the combo box,how can I do that? This is my code.

<select name="pname" class="textfields" id="model"  style="width:180px;"    onchange="getVal1();">
    <option id="0" >--Select Patient Name--</option>
     <?php
        $con=mysqli_connect("localhost","root","","dbnpatient");
            if (mysqli_connect_errno()){
              echo "Failed to connect to MySQL: " . mysqli_connect_error();
            }
        $pnum=$_GET['pnum'];
        $query = mysqli_query($con, "SELECT * FROM tblnpatient");
        while($row = mysqli_fetch_array($query)){
            $pnum = $row['pnum'];
            $pname = $row['pname'];
            $addr = $row['addr'];
            $complaints = $row['complaints'];
    ?>

    <option id="<?php echo $pnum; ?>" data-pnum="<?php echo $pnum; ?>" data-addr="      <?php echo $addr; ?>" data-    complaints="<?php echo $complaints; ?>"  value="<?php echo $pname; ?>"><?php echo $pname; ?></option>
    <?php } ?>




    //this is my code for filtering the table and having trouble because the $pname is undefined

    <?php
            $con=mysqli_connect("localhost","root","","dbnpatient");
            if (mysqli_connect_errno()){
              echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
             $pname=$_GET['pname'];
            $result = mysqli_query($con,"SELECT * FROM tbldiagnosis
            WHERE pname='$pname'");

            while($row = mysqli_fetch_array($result)) {
            echo '<tr class="record">';
            echo '<td>'.$row['diagnosis'].'</td>';
}
?>

Recommended Answers

All 3 Replies

$pname=$_GET['pname'];

change to

$pname=isset($_GET['pname']);

$pname=$_GET['pname'];

Update

$pname=isset($_GET['pname']);

Please Mark the question "Solved" when Your Problem is solved.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.