状态“付费”时禁用PAY按钮

问题描述 投票:0回答: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;
                    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> 

代码视图:

enter image description here

现在想要在支付状态时禁用付费按钮。

javascript php mysql
3个回答
0
投票

如果您不想显示付费订单的付款按钮,则可以添加如下所示的条件:

<?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 } ?>

您还可以将按钮显示为付费,并使用if else条件删除其上的链接,如下所示:

<?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 } ?>

0
投票
<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>

<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>

0
投票
<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>

© www.soinside.com 2019 - 2024. All rights reserved.