Eng Tat Chew
Eng Tat Chew

Reputation: 55

Extra column in HTML table

May I know how come there is one extra column at my table between the payment id and update payment column which I could not debug? My code is below. Note: I could not post the picture as I do not have enough reputation.

  <td width="52">Bookng id</td>     
    <td width="78">Deposit</td>
    <td width="149">Total_amt_paid</td>
    <td width="149">Balance</td>
    <td width="149">Payment status</td>
    <td width="57">Card type</td>
     <td width="62">Total price</td>
     <td width="94">Payment id</td>
     <td width="62"></td>
    <td width="293">Update Payment</td>
  </tr>
  <?php do { ?>
  <tr>
    <th height="45"><?php echo $row_RecordsetUpdatePayment['Booking_id']; ?></th>

    <th><?php echo $row_RecordsetUpdatePayment['Deposit']; ?></th>
    <th><?php echo $row_RecordsetUpdatePayment['Total_amt_paid']; ?></th>
    <th><?php echo $row_RecordsetUpdatePayment['Balance']; ?></th>
    <th><?php echo $row_RecordsetUpdatePayment['Payment_status']; ?></th>
    <th><?php echo $row_RecordsetUpdatePayment['Card_type']; ?></th>
    <th><?php echo $row_RecordsetUpdatePayment['Total_price']; ?></th>
    <th><?php echo $row_RecordsetUpdatePayment['Payment_id']; ?></th>
   <th><?php if($row_RecordsetUpdatePayment['Payment_status'] == 'Fully Paid'){
               echo "<th><span style='color:grey' href='UpdatePayment.php?Payment_id=".$row_RecordsetUpdatePayment['Payment_id']."'> Update</span></th>"; }
              if($row_RecordsetUpdatePayment['Payment_status'] == 'Partial'){ 
              echo "<th><a href='UpdatePayment.php?Payment_id=".$row_RecordsetUpdatePayment['Payment_id']."'> Update</a></th>";
              }
               ?>
             </th>

Upvotes: 0

Views: 2271

Answers (2)

Mindastic
Mindastic

Reputation: 4131

I see two problems in your code:

First, you should get rid of your empty in the first row

<tr>
    <td width="52">Bookng id</td>     
    <td width="78">Deposit</td>
    <td width="149">Total_amt_paid</td>
    <td width="149">Balance</td>
    <td width="149">Payment status</td>
    <td width="57">Card type</td>
    <td width="62">Total price</td>
    <td width="94">Payment id</td>
    <td width="293">Update Payment</td>
</tr>

Second, you are opening a <th> tag and checking a condition inside and opening a new <th> tag inside the condition, so your code should be something like:

<th><?php echo $row_RecordsetUpdatePayment['Deposit']; ?></th>
<th><?php echo $row_RecordsetUpdatePayment['Total_amt_paid']; ?></th>
<th><?php echo $row_RecordsetUpdatePayment['Balance']; ?></th>
<th><?php echo $row_RecordsetUpdatePayment['Payment_status']; ?></th>
<th><?php echo $row_RecordsetUpdatePayment['Card_type']; ?></th>
<th><?php echo $row_RecordsetUpdatePayment['Total_price']; ?></th>
<th><?php echo $row_RecordsetUpdatePayment['Payment_id']; ?></th>
<?php if($row_RecordsetUpdatePayment['Payment_status'] == 'Fully Paid') {
  echo "<th><span style='color:grey' href='UpdatePayment.php?Payment_id=".$row_RecordsetUpdatePayment['Payment_id']."'> Update</span></th>";
} else {
echo "<th><a href='UpdatePayment.php?Payment_id=".$row_RecordsetUpdatePayment['Payment_id']."'> Update</a></th>";
} ?>

That should be it.

Upvotes: 1

Cohan
Cohan

Reputation: 4564

Remove the extra <td> from your header row

<tr>
    <td width="52">Bookng id</td>     
    <td width="78">Deposit</td>
    <td width="149">Total_amt_paid</td>
    <td width="149">Balance</td>
    <td width="149">Payment status</td>
    <td width="57">Card type</td>
    <td width="62">Total price</td>
    <td width="94">Payment id</td>
    <td width="293">Update Payment</td>
</tr>

Upvotes: 0

Related Questions