<?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();
?>
if that product is getting low then will change color to red but its doing the whole column if that makes sense I just wanna do one row out of the column.
I am only trying to change the $row[count] trying to change single column based on the count. If count is under 10 then it will change to red. if not nothing happens?
2
Answers
Its all fixed it was me not paying attention to thing signs I was using.
if your table displays multiple rows please share the query and the source code of the foreach, anyway i see lot of problem in your code:
<image>
tag does not exist in html and it does not need a closing tag, the correct format:<img src="" />
you make the alert table td in one line: