mercredi 18 avril 2018

how we fetch some records with while loop and some without loop

i want to show some records with while loops and some without loops. but i trying while loop ignore first record and show other records.

    if (isset($_SESSION['patient_no'])) {
                $patient_id = $_SESSION['patient_no'];
                $sql = $db->prepare("select * from patient_record JOIN medicine_potency ON  reference_no=:reference_id and patient_code=:reference_no");
                if (!$sql) {
                    echo $sql->errorInfo();
                } else {
                    $sql->bindParam('reference_id', $patient_id, PDO::PARAM_INT);
                    $sql->bindParam('reference_no', $patient_id, PDO::PARAM_INT);
                    $sql->execute();
                    $sql->bindColumn('code', $id);
                    $sql->bindColumn('reference_no', $reference_no);
                    $sql->bindColumn('patient_name', $patient_name);
                    $sql->bindColumn('father_name', $father_name);
 if ($sql->columnCount() > 0) {
                     $sql->fetch(PDO::FETCH_ASSOC);

                            ?>
                        <tr bgcolor=" #005A04"><td colspan="2" style="text-align: center; color:#CCFFBB">Personal Information</td></tr>
                            <tr>
                                <td>Reference No</td>
                                <td><?php echo $reference_no; ?></td>
                            </tr>
                        <tr>
                                <td>Patient Name</td>
                                <td><?php echo $patient_name; ?></td>
                        </tr><?php while ($sql->fetch(PDO::FETCH_ASSOC)) {
                           ?>
                            <tr>
                                <td><?php echo $medicine; ?></td>
                                <td><?php echo $potency; ?></td>
                            </tr>




Aucun commentaire:

Enregistrer un commentaire