Reputation: 165
This is my php code:
if ($value = $rec['ip'] <= $cphigh_ip && $cplow_ip <= $value = $rec['ip'])
{
$cpyes="on ";
$realString = $value = $rec['ip'];
$whmLink=$realString[strlen($realString)-1];
}
else
{
$cpno="not on cPanel";
}
And the HTML table I have is pretty simple:
<tr>
<td>Domain IP:</td>
<td><?=$ipyes.$ipno.$cpyes.$cpno;?><input type="submit" name="cPanelButton" onClick="window.location.href='https://cp<?=$whmLink; ?>.skycomp.ca:2087'" value="cPanel"></td>
</tr>
Is there a way to hide the button in the else clause? or even create the button in that specific in the if statement?
Upvotes: 0
Views: 465
Reputation: 171
You can put button in to php code
if ($value = $rec['ip'] <= $cphigh_ip && $cplow_ip <= $value = $rec['ip'])
{
$cpyes="on ";
$realString = $value = $rec['ip'];
$whmLink=$realString[strlen($realString)-1];
$ifwhmlink = '<input type="submit" name="cPanelButton" onClick="window.location.href=\'https://cp'.$whmLink.'.skycomp.ca:2087\'" value="cPanel">';
}
else
{
$cpno="not on cPanel";
$ifwhmlink = "";
}
<tr>
<td>Domain IP:</td>
<td><?=$ipyes.$ipno.$cpyes.$cpno.$ifwhmlink;?></td>
</tr>
Upvotes: 1
Reputation: 26160
One of a few different ways is to set a flag:
$show_button = TRUE;
if ($value = $rec['ip'] <= $cphigh_ip && $cplow_ip <= $value = $rec['ip'])
{
$cpyes="on ";
$realString = $value = $rec['ip'];
$whmLink=$realString[strlen($realString)-1];
} else {
$show_button = FALSE;
$cpno="not on cPanel";
}
Then, in your HTML, wrap it in an if
condition:
<?php if ($show_button) { ?>
<tr>
<td>Domain IP:</td>
<td><?=$ipyes.$ipno.$cpyes.$cpno;?><input type="submit" name="cPanelButton" onClick="window.location.href='https://cp<?=$whmLink; ?>.skycomp.ca:2087'" value="cPanel"></td>
</tr>
<?php } ?>
Which will hide the whole ROW. If you want to just hide the button, then:
<tr>
<td>Domain IP:</td>
<td><?php if ($show_button) { ?><?=$ipyes.$ipno.$cpyes.$cpno;?><input type="submit" name="cPanelButton" onClick="window.location.href='https://cp<?=$whmLink; ?>.skycomp.ca:2087'" value="cPanel"><?php } ?></td>
</tr>
Upvotes: 2