<?php
include './PHP/serverconn.php';
include './PHP/login.php';
$itemid = '';
$sql = "SELECT id, ItemName, ItemBarcode, CompanyName, OurBarcode, DetailsOnItem, barcodeimg, count, combindedBarcode, modelnumber FROM items";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {
$itemid = $row['id'];
?>
<tbody>
<tr id="<?php echo $row['id']; ?>" >
<th> <?php echo $row['id']; ?></th>
<td data-column='ItemName' id="ItemName"><?php echo $row['ItemName']; ?></td>
<td data-column='ItemBarcode' id="ItemBarcode"><?php echo $row['ItemBarcode']; ?></td>
<td data-column='CompanyName' id="CompanyName"><?php echo $row['CompanyName']; ?></td>
<td data-column='OurBarcode' id="OurBarcode"><?php echo $row['OurBarcode']; ?></td>
<td data-column='DetailsOnItem' id="DetailsOnItem"><?php echo $row['DetailsOnItem']; ?></td>
<td data-column='DetailsOnItem' id="DetailsOnItem"><?php echo $row['modelnumber']; ?></td>
<td data-column='barcodeimg' id="barcodeimg" class='warning'><image src='<?php echo $row['barcodeimg']; ?>'></img></td>
<td data-column="count"
class="<?=($row['count'] > 10 ? 'alert-danger' : 'alert-success');?>"
id="count">
<?php echo $row['count']; ?>
</td>
<td data-column='combindedBarcode' id="combindedBarcode"><?php echo $row['combindedBarcode']; ?></td>
<td>
<?php if($_SESSION['admin'] > 0){?>
<div class='btn-group'>
<button type='sumbit' name='edit' class='btn btn-sm btn-secondary' data-toggle="modal" data-target="#modal-large" >
<i class='fa fa-pencil'></i>
</button>
<a type='sumbit' name='delete' id='delete' href='/delete.php?id=<?php echo $itemid; ?>&logged_id=<?php echo $_SESSION['admin']; ?>' class='btn btn-sm btn-secondary' data-toggle='tooltip' title='Delete'>
<i class='fa fa-times'></i>
</a>
</div>
<?php ;} else { ?>
<div class='btn-group' disabled>
<button type='sumbit' name='edit' class='btn btn-sm btn-secondary' data-toggle="modal" data-target="#modal-large">
<i class='fa fa-pencil'></i>
</button>
<a type='sumbit' name='delete' id='delete' href='/delete.php?id=<?php echo $itemid; ?>&authed=<?php echo $_SESSION['admin']; ?>' class='btn btn-sm btn-secondary' data-toggle='tooltip' title='Delete' disabled>
<i class='fa fa-times'></i>
</a>
<?php ;} ?>
</td>
</tr>
<?php } ?>
</tbody>
<?php } else {
echo 'No results found';
}
$conn->close();
?>
如果乘积变小,则颜色将变为红色,但它将执行整个列,如果这有意义,我只想执行列中的一行。
我只是尝试更改$row[count],尝试根据计数更改单列。如果计数小于10,则它将变为红色。如果不是什么都没有发生?
2条答案
按热度按时间jbose2ul1#
如果你的表显示多行请分享查询和foreach的源代码,无论如何我看到很多问题在你的代码:
<image>
标记在html中不存在,并且不需要结束标记,正确格式为:<img src="" />
1.您可以在一行中创建警报表td:
1.如果要为整行着色:
rkue9o1l2#
这一切都是固定的,这是我没有注意的东西标志,我正在使用。