如何删除循环中的行或任何其他方法以显示如下所示

Needed Display enter image description here

Here my code and display

<table width="100%" cellspacing="0" cellpadding="0" summary="" id="box-table-a">
        <thead>
          <tr>
            <th width="" scope="col"><strong>Item Description</strong></th>
            <th scope="col" style="text-align:center;"><strong>Quantity</strong></th>
            <th width="350" scope="col"><strong>Supplier Name</strong></th>
            <th scope="col" style="text-align:center;"><strong>Unit Price Rs.</strong></th>
            <th scope="col" style="text-align:center;"><strong>VAT Price Rs.</strong></th>
            <th width="100" scope="col"><strong>Total Price Rs.</strong></th>
          </tr>
        </thead>
        <tbody>

          <?php 


          $get_data =mysql_query("SELECT supplier_add_quotaion_form.quotaion_request_id,supplier_add_quotaion_form.supplier_id,supplier_add_quotaion_form.supplier_add_quotaion_id,supplier_add_quotaion_request_item.* FROM supplier_add_quotaion_request_item,supplier_add_quotaion_form 
WHERE supplier_add_quotaion_form.supplier_add_quotaion_id=supplier_add_quotaion_request_item.supplier_add_quotaion_id AND supplier_add_quotaion_form.quotaion_request_id='$id' ORDER BY quotation_item_id");


            while($row = mysql_fetch_array($get_data)){ 
                $quotaion_request_id = $row['quotaion_request_id'];
                $supplier_add_quotaion_id = $row['supplier_add_quotaion_id'];
                $supplier_id = $row['supplier_id'];
                $net_item_value = $row['net_item_value'];
                $vat_item_value = $row['vat_item_value'];
                $total_value = $row['total_value'];
                $quotation_item_id = $row['quotation_item_id'];


                 $get_count = mysql_query("SELECT quotation_item_id FROM supplier_add_quotaion_request_item WHERE quotation_item_id='$quotation_item_id'"); 

                $count = mysql_num_rows($get_count);


                $get_quantity = mysql_query("SELECT quantity_required,item_description FROM clerk_add_quotaion_request_item WHERE quotation_item_id='$quotation_item_id'"); 

                    while($rowB = mysql_fetch_array($get_quantity)){ 
                        $quantity_required = $rowB['quantity_required'];
                        $item_description = $rowB['item_description'];
                    }



            ?>

          <tr>
            <td><?php echo $item_description; ?></td>
            <td align="center"><?php echo $quantity_required; ?></td>
            <td><?php echo $supplier_id; ?></td>
            <td align="center"><?php echo $net_item_value; ?></td>
            <td align="center"><?php echo $vat_item_value; ?></td>
            <td align="center"><?php echo $total_value; ?></td>
          </tr>

          <?php
            }
        ?>
        </tbody>

enter image description here

  • When Duplicate description coming need to rowspan them or what ever method need to show display as first image..i try it get count and then rowspan according to it.but unable to get need display,don't know how to delete extra cell
  • Duplicate row count not fixed,only example show first image,it can be range 1-7 duplicate for one description(for one item 7 suppliers able to bids)

supplier_add_quotaion_form table structure

supplier_add_quotaion_request_item

supplier_add_quotaion_request_item table structure

supplier_add_quotaion_form table structure

clerk_add_quotaion_request_item structure

enter image description here

You can do this in one pass,try this

<?php 
          $get_data =mysql_query("...");

          $last_quotaion_request_id = -1;
            while($row = mysql_fetch_array($get_data)){ 
                $quotaion_request_id = $row['quotaion_request_id'];
                $supplier_add_quotaion_id = $row['supplier_add_quotaion_id'];
                $supplier_id = $row['supplier_id'];
                $net_item_value = $row['net_item_value'];
                $vat_item_value = $row['vat_item_value'];
                $total_value = $row['total_value'];
                $quotation_item_id = $row['quotation_item_id'];


                 $get_count = mysql_query("SELECT quotation_item_id FROM supplier_add_quotaion_request_item WHERE quotation_item_id='$quotation_item_id'"); 

                $count = mysql_num_rows($get_count);


                $get_quantity = mysql_query("SELECT quantity_required,item_description FROM clerk_add_quotaion_request_item WHERE quotation_item_id='$quotation_item_id'"); 

                    while($rowB = mysql_fetch_array($get_quantity)){ 
                        $quantity_required = $rowB['quantity_required'];
                        $item_description = $rowB['item_description'];
                    }



            ?>

          <tr>
            <?php if($last_quotaion_request_id != $quotaion_request_id){ ?>
            <td rowspan="<?php echo $count; ?>"><?php echo $item_description; ?></td>
            <td rowspan="<?php echo $count; ?>" align="center"><?php echo $quantity_required; ?></td>
            <?php } ?>
            <td><?php echo $supplier_id; ?></td>
            <td align="center"><?php echo $net_item_value; ?></td>
            <td align="center"><?php echo $vat_item_value; ?></td>
            <td align="center"><?php echo $total_value; ?></td>
          </tr>

          <?php
            $last_quotaion_request_id = $quotaion_request_id;
            }
        ?>

It'll probably be FAR easier to slurp your query results into a structured array, from which you can then easily retrieve the necessary counts to do your rowspans:

$data = array();
while ($row = mysql_fetch_assoc($result)) {
   $data[$row['item_description']][] = $row;
}

echo "start your table here";
foreach($data as $description => $items) {
    echo "<tr><td rowspan=" . count($items) . ">";
    foreach($items as $item) {
        output item data here
    }
}

This won't work as is, but should give you an idea of how to go about it.

you need to change the structure of table you are using. as per my guessing I'm giving a suggestion. keep the item description in a table and the quotation details in another table. and while fetching the data you can fetch using group by sql command.

your item table may be like this:

 1. id
 2. desc
 3. clicks

and quotation table may be like this

 1. id
 2. item_id
 3. supplier
 4. quantity
 5. vat
 6. price

etc.