**What I have:** 

1.I have two DB tables `display` and `bid` as listed below: 

```
mysql> select * from display where gp_no = 1;

+-------+--------------+-----------+--------------------+---------------+-----------+----------------+
| gp_no | no_of_member | amount    | current_instalment | starting_date | member_no | member_name    |
+-------+--------------+-----------+--------------------+---------------+-----------+----------------+
|     1 |           15 | 375000.00 |                  2 | 2015-05-01    |         1 | Akansha Gupta  |
|     1 |           15 | 375000.00 |                  2 | 2015-05-01    |         2 | Akash Bansal   |
|     1 |           15 | 375000.00 |                  2 | 2015-05-01    |         3 | Ashish Gupta   |
|     1 |           15 | 375000.00 |                  2 | 2015-05-01    |         4 | Chavi Jain     |
|     1 |           15 | 375000.00 |                  2 | 2015-05-01    |         5 | Dhruv Goel     |
|     1 |           15 | 375000.00 |                  2 | 2015-05-01    |         6 | Mukul Gupta    |
|     1 |           15 | 375000.00 |                  2 | 2015-05-01    |         7 | Nancy Aggarwal |
|     1 |           15 | 375000.00 |                  2 | 2015-05-01    |         9 | Prateek Jain   |
|     1 |           15 | 375000.00 |                  2 | 2015-05-01    |        11 | Rajender Gupta |
|     1 |           15 | 375000.00 |                  2 | 2015-05-01    |        12 | S K Goel       |
|     1 |           15 | 375000.00 |                  2 | 2015-05-01    |        13 | Sadhna Goel    |
|     1 |           15 | 375000.00 |                  2 | 2015-05-01    |        15 | Sandeep Jain   |
|     1 |           15 | 375000.00 |                  2 | 2015-05-01    |        16 | Sunil Jain     |
|     1 |           15 | 375000.00 |                  2 | 2015-05-01    |        17 | Sunil Sharma   |
|     1 |           15 | 375000.00 |                  2 | 2015-05-01    |        19 | Sunita Gupta   |
+-------+--------------+-----------+--------------------+---------------+-----------+----------------+
15 rows in set (0.00 sec)

mysql> select date , member_no from bid where gp_no = 1 order by member_no asc;
+------------+-----------+
| date       | member_no |
+------------+-----------+
| 2015-06-01 |         7 |
| 2015-05-01 |        16 |
+------------+-----------+
2 rows in set (0.00 sec)

```

**What I want :** 

1. I want to compare the `member_no` from both the tables and where I get a match It should display date from table `bid` else it should display **Not Withdraw**. With the code I'm using , I'm able to display only first date i.e., only first match . I probably knows that its because of the mismatch in the no. of rows of both the tables.

[![This is what I'm getting](https://i.stack.imgur.com/bRimk.png)](https://i.stack.imgur.com/bRimk.png)

But it should also display the date in front of the `member_no = 16`. 

**PHP Code**

```
$sql = "select * from display where gp_no = '$gp_no' ";
$result = mysqli_query($conn, $sql);

$s_no = 1 ; 
if (mysqli_num_rows($result) > 0)
{

 $s = " select date,member_no  from bid where gp_no = '$gp_no ' order by member_no asc"; 
 $r = mysqli_query($conn, $s);
 if (mysqli_num_rows($r) > 0)
  {
    ?> <h1>Welcome !!! Details of GROUP NO : <?php echo $gp_no ;  ?></h1> 
     <table  align = center ; style="width:50%">
     <tr><th><?php echo " Group Number ";?> </th><td><?php echo $gp_no ; ?></td></tr>
     <tr><th><?php echo " Number of Members ";?> </th><td><?php echo $no_of_member ; ?></td></tr>
     <tr><th><?php echo " Amount ";?> </th><td><?php echo $amount ; ?></td></tr>
     <tr><th><?php echo " Starting Date ";?> </th><td><?php echo $starting_date ; ?></td></tr>
     <tr><th><?php echo " Current Instalment ";?> </th><td><?php echo $current_instalment ; ?></td></tr>
     </table>
     <table  align = center ; style="width:50%" id = " display">
    <tr><th><?php echo "  Sr. Number ";  ?> </th><th><?php echo "  Member Number ";  ?> </th><th><?php echo "  Member Name ";  ?> </th><th><?php echo "  Bid Withdraw ";  ?> </th></tr>
   <?php
   /*$row_count = mysqli_num_rows($result);
   $row1_count = mysqli_num_rows($r);
   $remaining_rows = max($row_count, $row1_count);
   while($remaining_rows-- > 0)
{
    $row = mysqli_fetch_assoc($result);
    $row1 = mysqli_fetch_assoc($r); */
     while($row1 = mysqli_fetch_assoc($r))
     {
         while($row = mysqli_fetch_assoc($result))
    { 

      ?>
     <tr>
        <td><?php echo $s_no ; ?></td>

        <td><?php echo $row["member_no"] ; ?></td>

        <td><?php echo $row["member_name"] ; ?></td>
    <?php
     if($row["member_no"] === $row1["member_no"])
    {
    ?>
       <td><?php echo $row1["date"] ; ?></td>
    <?php 
     }
    else
     { ?> 
       <td><?php echo " Not withdrawn "; ?></td> 
       <?php } ?> 
   </tr> 
  <?php
       $s_no = $s_no + 1;
        }
        } 
        ?>
  </table>  
      <?php 
        }
            } 
    else
    {
    ?> <h1>  Members not associated yet. </h1> <?php
    }
   }
  mysqli_close($conn);
 ?>

```