PHP If Else-隐藏按钮

PHP If Else - Hide Button

本文关键字:按钮 隐藏 Else- If PHP      更新时间:2023-09-26

我正在想办法!

我有以下代码

if ($value = $rec['ip'] <= $cphigh_ip && $cplow_ip <= $value = $rec['ip']) {
     $cpyes="on ";
     $number= $value = $rec['ip'];
     $whmLink=$number[strlen($number)-1];
    }
    else {
     $cpno="not on cPanel";
    }

我在这个下面还有一个按钮

<td><input type="submit" name="cPanelButton" onClick="window.location.href='https://www.<?=$variable; ?>.test.com'" value="cPanel"></td>

我想在else上添加一个隐藏按钮的地方——有什么想法吗?

编辑:

?>
<table border=1>
    <tr>
        <td>Domain IP:</td>
        <td><?=$ipyes.$ipno.$cpyes.$cpno;?><input type="submit" name="cPanelButton" onClick="window.location.href='https://www.<?=$variable; ?>.test.com'" value="cPanel"></td>
    </tr>
    <tr>
        <td>Mail Exchange:</td>
        <td><?=$yesMail.$yesHost.$noMail;?></td>
    </tr>
    <tr>
        <td>Key DNS Records:</td>
        <td colspan='2'><?=$dnsString;?></td>
    </tr>
</table>
<?php

您可以将按钮移动到if块中:

if ($value = $rec['ip'] <= $cphigh_ip && $cplow_ip <= $value = $rec['ip']) {
    $cpyes="on ";
    $number= $value = $rec['ip'];
    $whmLink=$number[strlen($number)-1];
    ?>
        <td><input type="submit" name="cPanelButton" onClick="window.location.href='https://www.<?=$variable; ?>.test.com'" value="cPanel"></td>
    <?php
}
else {
    $cpno="not on cPanel";
    ?>
        <td></td>
    <?php
}

然而,您可能更喜欢对表示和逻辑进行更多的分离,以防止代码变得过于丑陋。