Disable PAY Button when status “paid”

141
December 26, 2017, at 7:05 PM

I want to disable pay button when status paid.

My Code:

<table id="simple-table" class="table  table-bordered table-hover">
    <thead>
        <tr>
            <th width="30%">Month </th>
            <th width="20%">DPS Amount</th>
            <th width="20%">Status</th>
            <th width="30%">Options</th>
        </tr>
    </thead>
    <tbody>
            <?php
                    $acc=$_GET['acc'];
                    $result = $db->prepare("SELECT * FROM dps_schedule WHERE account_number= :userid");
                    $result->bindParam(':userid', $acc);
                    $result->execute();
                    $counter = 0;
                    for($i=0; $row = $result->fetch(); $i++){
            ?>
        <tr class="record">
            <td>Month-<?php echo ++$counter; ?></td>
            <td><?php echo $row['dps_payment']; ?></td>
            <td class="status"><?php echo $row['status']; ?></td>
            <td class="dis"><a rel="facebox" href="dps_installment.php?id=<?php echo $row['id']; ?>"><button class="btn btn-success btn-mini"><i class="icon-edit"></i> PAY </button></a></td>
            </tr>
            <?php
                }
            ?>
    </tbody>
</table> 

Code View:

Now want to disable pay button when status paid.

Answer 1

You can add if condition like below if you don't want to show Pay Button for Paid Orders :

<?php if($row['status']!="Paid"){ ?> 
    <td class="dis"><a rel="facebox" href="dps_installment.php?id=<?php echo $row['id']; ?>"><button class="btn btn-success btn-mini"><i class="icon-edit"></i> PAY </button></a></td> 
<?php } ?>

You can also show the button as Paid and remove the link over it with if else condition like below:

<?php if($row['status']=="Paid"){ ?> 
    <td class="dis"><button class="btn btn-success btn-mini"><i class="icon-edit"></i> PAID </button></td>
<?php } else { ?>
    <td class="dis"><a rel="facebox" href="dps_installment.php?id=<?php echo $row['id']; ?>"><button class="btn btn-success btn-mini"><i class="icon-edit">
</i> PAY </button></a></td> 
<?php } ?>
Answer 2
<td class="dis"><a rel="facebox" href="dps_installment.php?id=<?php echo $row['id']; ?>"><button class="btn btn-success btn-mini"><i class="icon-edit"></i> PAY </button></a></td>

to

<td class="dis"><a rel="facebox" href="dps_installment.php?id=<?php echo $row['id']; ?>"><button class="btn btn-success btn-mini <?php if($row['status'] =="paid"){ echo "disabled";}?>"><i class="icon-edit"></i> PAY </button></a></td>
Answer 3
<table id="simple-table" class="table  table-bordered table-hover">
<thead>
    <tr>
        <th width="30%">Month </th>
        <th width="20%">DPS Amount</th>
        <th width="20%">Status</th>
        <th width="30%">Options</th>
    </tr>
</thead>
<tbody>
        <?php
                $acc=$_GET['acc'];
                $result = $db->prepare("SELECT * FROM dps_schedule WHERE account_number= :userid");
                $result->bindParam(':userid', $acc);
                $result->execute();
                $counter = 0;
                $button = '<button class="btn btn-success btn-mini"><i class="icon-edit"></i> PAY </button>';
                for($i=0; $row = $result->fetch(); $i++){                       
                    if( $row['status']=='unpaid') $sbutton = '<a rel="facebox" href="dps_installment.php?id='.$row['id'].'">'.$button.'</a>'; //check here the status if unpaid add button with link                        
        ?>
    <tr class="record">
        <td>Month-<?php echo ++$counter; ?></td>
        <td><?php echo $row['dps_payment']; ?></td>
        <td class="status"><?php echo $row['status']; ?></td>
        <td class="dis"><?php echo $sbutton; ?></td><!--Add $sbutton here with contain link-->
        </tr>
        <?php
            }
        ?>
</tbody>

READ ALSO
MySQL Select the field as Distinct having data type as Text with filtering

MySQL Select the field as Distinct having data type as Text with filtering

If we have a table T1 with a field named orders have data type as Text

130
Mysql Optimization suggestion for large table

Mysql Optimization suggestion for large table

i want to optimize this query,

122
Script for tacking mysql backup in ubuntu 16

Script for tacking mysql backup in ubuntu 16

Plz help me to write the script in ubuntu for tacking mysql backup,I have already written few line in the scriptsh file for tacking mysql dump and run this script from crontab, but it is not working

213
Google CHARTS Display 0 values. (MySQL data with datetime)

Google CHARTS Display 0 values. (MySQL data with datetime)

I have been struggling with google charts with MySQL data

273