1

需要显示 在此处输入图像描述

这是我的代码和显示

<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>

在此处输入图像描述

  • 当重复的描述需要对它们进行行跨度或任何方法需要将显示显示为第一张图像时..我尝试获取计数,然后根据它进行行跨度。但无法获得需要显示,不知道如何删除额外的单元格
  • 重复行数不固定,仅示例显示第一张图片,一个描述的范围可以是 1-7 个重复(对于一个项目,7 个供应商可以投标)

Supplier_add_quotaion_form 表结构

供应商_add_quotaion_request_item

Supplier_add_quotaion_request_item 表结构

Supplier_add_quotaion_form 表结构

clerk_add_quotaion_request_item 结构

在此处输入图像描述

4

3 回答 3

0

将查询结果放入结构化数组中可能会更容易,然后您可以从中轻松检索必要的计数来执行行跨度:

$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
    }
}

这不会按原样工作,但应该让您了解如何去做。

于 2012-12-13T15:46:26.140 回答
0

你可以一次完成,试试这个

<?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;
            }
        ?>
于 2012-12-13T15:55:11.130 回答
0

您需要更改正在使用的表的结构。根据我的猜测,我给出了一个建议。将项目描述保存在一个表格中,将报价详情保存在另一个表格中。在获取数据时,您可以使用 group by sql 命令获取数据。

您的项目表可能是这样的:

 1. id
 2. desc
 3. clicks

和报价表可能是这样的

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

等等

于 2012-12-13T15:59:18.647 回答