1

I want my table to look like this image:

What I Want?

My table looks like this image:

What it is?

So, how to do that?

How my table is generated:

<table id="chiru_inv" class="table table-striped table-hover table-bordered table-responsive">
   <tr>
    <td colspan="4" align="center">
      <h1>Company</br><span style="font-size: 75%;">Number</span></h1>
    </td>
  <tr>
    <td colspan="2">
      <h3><span style="float: left;">Bill No.: 4</span></h3>
    </td>
    <td colspan="2">
      <h3><span style="float: right;">Date: </span></h3>
    </td>
  </tr>
  </tr>
  <tr>
    <td colspan="4">
      <h3>Customer: </h3>
    </td>
  </tr>
  <tr>
    <th>Sr.</th>
    <th>Item</th>
    <th>Qty</th>
    <th>Amount</th>
  </tr>
    <?php
    $i = 0;
    $total = 0;
        while($rowc)
        {
            extract($rowc);
            $i++;

?>

    <tr>
      <td style="border-top:none !important; border-bottom:none !important;">
      <?php echo $i; ?>
      </td>
      <td style="border-top:none !important; border-bottom:none !important;">
      <?php
      $itm = $IRN;
      $stmti = $user_home->runQuery('SELECT * FROM item WHERE IRN = :iinv ');
    $stmti->bindParam(':iinv',$itm);
    $stmti->execute();
    $rowci = $stmti->fetch(PDO::FETCH_ASSOC); 
      echo $rowci['Name']; 
      $srv = $SRN;
      $stmts = $user_home->runQuery('SELECT * FROM service WHERE SRN = :sinv ');
    $stmts->bindParam(':sinv',$srv);
    $stmts->execute();
    $rowcs = $stmts->fetch(PDO::FETCH_ASSOC); 
      ?>
      &nbsp;(<?php echo $rowcs['Name']; ?>)
      </td>
      <td style="border-top:none !important; border-bottom:none !important;">
      <?php echo $Quantity; ?>
      </td>
      <td style="border-top:none !important; border-bottom:none !important;">
      <?php echo $Amnt; ?>
      </td>
    </tr>

            <?php
            $total = $total + $Amnt;
        $rowc=$stmt->fetch(PDO::FETCH_ASSOC);
        }
        ?>

    <tr>
      <td colspan="2"><strong><?php echo getIndianCurrency($total); ?>Only</strong></td>
      <td><strong>Total:</strong></td>
      <td><strong><?php echo $total; ?></strong></td>
    </tr>

</table>

The table can have only 1 row, or 2 or it can have 4 rows also!

For all the rows, table should always be like this only.

enter image description here

The rows of the table change according to the records in the database.

Alive to die - Anant
  • 70,531
  • 10
  • 51
  • 98
BTC
  • 71
  • 7

1 Answers1

0
    <table id="chiru_inv" class="table table-striped table-hover table-bordered table-responsive">
       <tr>
        <td colspan="4" align="center">
          <h1>Company</br><span style="font-size: 75%;">Number</span></h1>
        </td>
      <tr>
        <td colspan="2">
          <h3><span style="float: left;">Bill No.: 4</span></h3>
        </td>
        <td colspan="2">
          <h3><span style="float: right;">Date: </span></h3>
        </td>
      </tr>
      </tr>
      <tr>
        <td colspan="4">
          <h3>Customer: </h3>
        </td>
      </tr>
      <tr>
        <th>Sr.</th>
        <th>Item</th>
        <th>Qty</th>
        <th>Amount</th>
      </tr>
        <?php
    $i = 0;
    $total = 0;
    $stmttr = $user_home->runQuery("SELECT * FROM invoice WHERE BRN = :inv"); // Your query
    $stmttr->bindParam(':inv',$irn);
$allRows = $stmttr->rowCount(); // Count Total rows available in result
$tri = 0; // initiate variable to check <tr> status
        while($rowc)
        {
            extract($rowc);
            $i++;

?>

    <tr  <?php if(++$tri==$allrows) { ?> style="padding-bottom: 100px;"<?php } ?>   >
          <td style="border-top:none !important; border-bottom:none !important;">
          <?php echo $i; ?>
          </td>
          <td style="border-top:none !important; border-bottom:none !important;">
          <?php
          $itm = $IRN;
          $stmti = $user_home->runQuery('SELECT * FROM item WHERE IRN = :iinv ');
        $stmti->bindParam(':iinv',$itm);
        $stmti->execute();
        $rowci = $stmti->fetch(PDO::FETCH_ASSOC); 
          echo $rowci['Name']; 
          $srv = $SRN;
          $stmts = $user_home->runQuery('SELECT * FROM service WHERE SRN = :sinv ');
        $stmts->bindParam(':sinv',$srv);
        $stmts->execute();
        $rowcs = $stmts->fetch(PDO::FETCH_ASSOC); 
          ?>
          &nbsp;(<?php echo $rowcs['Name']; ?>)
          </td>
          <td style="border-top:none !important; border-bottom:none !important;">
          <?php echo $Quantity; ?>
          </td>
          <td style="border-top:none !important; border-bottom:none !important;">
          <?php echo $Amnt; ?>
          </td>
        </tr>

                <?php
                $total = $total + $Amnt;
            $rowc=$stmt->fetch(PDO::FETCH_ASSOC);
            }
            ?>

        <tr>
          <td colspan="2"><strong><?php echo getIndianCurrency($total); ?>Only</strong></td>
          <td><strong>Total:</strong></td>
          <td><strong><?php echo $total; ?></strong></td>
        </tr>

    </table>
helpdoc
  • 1,910
  • 14
  • 36