How to enable and disable links in php

George Saad picture George Saad · Sep 6, 2012 · Viewed 9k times · Source

I'm trying to make an if statement to enable and disable user account in href link but I want the link display Disable if the Query return active = 1 and enable if the query return 0.

Answer

Abid Hussain picture Abid Hussain · Sep 6, 2012

Try this:-

$link = '';
if($status == 1)
{
    $link ='<a href="">Profile</a>';
}

echo $link;

Update

function member_enable(){
    $command = mysql_query("SELECT COUNT(member_id) FROM members WHERE active= 1");
    $num_rows = mysql_num_rows($command);

    return $num_rows; 
} 

$status  = member_enable();
if($status >= 1)
{
    echo "<a href='enable_member.php?enab=". urlencode($result['member_id'])."' class=\"button-small blue text_upper round\">Enable</a>";

}else{

    echo "<a href='disable_member.php?deac=" . urlencode($result['member_id'])."' class=\"button-small blue text_upper round\">Deactivate</a>";
}