JCD JCD - 8 months ago 40
jQuery Question

PHP - If database record is a specific value, only show these buttons

I have a multi-step form that allows the user to save for later or submit. If they save for later, i want them to have an option to edit or delete but if they submit, i dont want them to have any option to edit or delete. Although the following code makes sense, its not working; i'm not getting any buttons and it breaks the jquery table plugin and i dont have the search or pagination option:

<table id="myTable" class="table table-bordered table-hover table-striped tablesorter table-responsive">
<td>Serial Number</td>
<td>Grand Total</td>
while($res = mysqli_fetch_array($result)) {
echo "<tr>";
echo "<td>".$res['id']."</td>";
echo "<td><span class='label ".$res['labelwarning']."'>".$res['status']."</span></td>";
echo "<td>".$res['todaysdatetime']."</td>";
echo "<td>".$res['tag']."</td>";
echo "<td>".$res['serialnumber']."</td>";
echo "<td>".$res['currentequipment']."</td>";
echo "<td>".$res['company']."</td>";

echo "<td>".$res['total_grandtotal']."</td>";

$Submitted = "Submitted";
$Saved = "Saved";

if ($res['labelwarning'] == $Submitted) {
echo "<td></td>";

} elseif ($res['labelwarning'] == $Saved) {
echo "<td><a href=\"invoices_edit.php?id=$res[id]\" class='btn btn-info fa fa-pencil-square'></a> | <a href=\"invoices_delete.php?id=$res[id]\" class='btn btn-danger fa fa-trash' onClick=\"return confirm('Are you sure you want to delete?')\"></a></td>";

echo "</tr>";



$(document).ready(function() {

"aaSorting": [ [0,'desc'] ]



Try to change your if/else part to this:

    if ($res['labelwarning'] == $Submitted) {
        echo "<td></td>";
    } else{
        echo "<td><a href='invoices_edit.php?id=$res[id]' class='btn btn-info glyphicon glyphicon-pencil'></a> | <a href='invoices_delete.php?id=$res[id]' class='btn btn-danger glyphicon glyphicon-trash' onClick=\"return confirm('Are you sure you want to delete?')\"></a></td>";