1

I have many tables and I need to select data from there and display in my HTML table.

I need to execute two queries now in order to display all results.

However, I can only put one query within my code. My code is below:

<?php
$stmt = $DB_con->prepare("SELECT * FROM applicantpersonaldetails apd "
        . "INNER JOIN employementdetails ed ON apd.ApplicantID = ed.ApplicantID "
        . "INNER JOIN sourceoffunds sof ON apd.ApplicantID = sof.ApplicantID "
        . "WHERE apd.AccountID =:accountId AND apd.applicantType ='main';");


$stmt->bindParam(':accountId', $accountId, PDO::PARAM_INT);
$stmt->execute();
if ($stmt->rowCount() > 0) {
    ?>                                    


    <table id="01">

        <tr>
            <th></th>
            <th>Main Applicant</th>
            <th>Joint Applicant1</th>

        </tr>
        <?php
        while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
            ?>
            <tr>
                <td>Name</td>
                <td><input name="nameMain"></td>
                <td><input name="nameJoint1"></td>

            </tr>
            <tr>
                <td>Occupation</td>
                <td><input type="text" id="occupationMain" name="occupationMain" value="<?php echo $row['EmploymentStatus']; ?>" readonly></td>
                <td><input type="text" id="occupationJoint1" name="occupationJoint1" value="" readonly></td>
            </tr>
            <tr>
                <td>Employment</td>
                <td>
                    <div>
                        <input list="employTypeList" name="employTypeMain" id="employTypeMain" value="" readonly>
                    </div>
                </td>
                <td>
                    <input list="employTypeList" name="employTypeJoint1" id="employTypeJoint1" value="" readonly >

                </td>
            </tr>
            <tr>
                <td>Company</td>
                <td><input type="text"   id="companyMain" name="companyMain" value="" readonly></td>
                <td><input type="text"   id="companyJoint1" name="companyJoint1" value=""readonly></td>
            </tr>

        </table>
        <?php
    }
} else {
    ?>
    <div class="">
        <div class="alert alert-warning">
            <span class="glyphicon glyphicon-info-sign"></span> &nbsp; No Data Found ...
        </div>
    </div>
<?php }
?>

For now, I want to insert another SQL query into my code in order to display the result for joint1

The other query is below:

    $stmt = $DB_con->prepare("SELECT * FROM applicantpersonaldetails apd "
            . "INNER JOIN employementdetails ed ON apd.ApplicantID = ed.ApplicantID "
            . "INNER JOIN sourceoffunds sof ON apd.ApplicantID = sof.ApplicantID "
            . "WHERE apd.AccountID =:accountId AND apd.applicantType ='joint1';");
$stmt->bindParam(':accountId', $accountId, PDO::PARAM_INT);
$stmt->execute();
0

1 Answer 1

2

They're the same query just looking for different applicant types, so just use AND apd.applicantType IN ('main','joint1')

Sign up to request clarification or add additional context in comments.

1 Comment

As the data is under the same table, how to make sure the other column is getting the data for the joint1?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.