【发布时间】:2015-01-28 05:42:33
【问题描述】:
大家好,我有问题要问你
我正在开发商店管理系统,我想从商店表中选择所有数据并以 html 表格格式显示它到目前为止我已经尝试使用下面的代码显示它
名称............商店......数量............单位
门............ store1............970...... pcs......决定
办公桌........... store2.............10000.......pcs.... ..决定
门............ store1............50...... ..pcs......决定
<table class="table table-striped table-bordered bootstrap-datatable datatable responsive">
<thead>
<tr>
<th>Item</th>
<th>name</th>
<th>location</th>
<th>Quantity</th>
<th>Unit</th>
</tr>
</thead>
<tbody>
<?php
if (isset($_POST['search'])){
foreach ($_POST['name'] as $attrib) {
$query = mysql_query("select * from store where name= '".$attrib."'") or die(mysql_error());
$num_row = mysql_num_rows($query);
while ($row = mysql_fetch_array($query)) {
$id = $row['id'];
?>
<tr class="del<?php echo $id ?>">
<td><?php echo $row['id']; ?></td>
<td><?php echo $row['name']; ?></td>
<td><?php echo $row['location']; ?></td>
<td><?php echo $row['quantity']; ?></td>
<td><?php echo $row['unit']; ?></td>
<td>
<a href="inventorysearch.php<?php echo '?id='.$id; ?>"><i class="glyphicon glyphicon-ok"></i> Decide</a></li>
</td>
但我需要显示的是仅从数据库中为那些重复的名称选择分组名称,并像下面那样显示它。
名称............Store1........Store2........Store3
门............ 970............50...... ..........0........决定
办公桌............ 10............10000............ ......0........决定
【问题讨论】:
标签: mysql