0

I want to make IF Else Condition on the basis of User Login ID for their edit or delete Option.

<?php
    $ask_filter['Ask_Id']=$userlogined;
    if($user_id="$userlogined"){

        <div class="query_edit fl"><a href="queryedit.php?ID=<?=$ask_filter['Ask_Id']?>">EDIT</a></div>

    }else{}
?>

I apply this query but its not working.

Anant Kumar Singh
  • 68,309
  • 10
  • 50
  • 94

2 Answers2

0
<?php
$ask_filter['Ask_Id']=$userlogined;
if($user_id == $userlogined){

    <div class="query_edit fl"><a href="queryedit.php?ID=<?=$ask_filter['Ask_Id']?>">EDIT</a></div>

}else{}

?>

user2901901
  • 101
  • 10
  • 1
    While this code may answer the question, it would be better to include some context, explaining how it works and when to use it. Code-only answers are not useful in the long run. – Bono Apr 30 '16 at 14:20
0

You used a single equal sign, thereby assigning your variable instead of testing for equality.

Always use ==in If... Elsestructures.

To be sure not to miss this error it's a good practice to put the constant as first element of your test : If ("login" == $variable) This way your code will generate an error, as it is impossible to assign a constant.

This good practice works for nearly all languages, it will even cause compilation error in compiled languages.

Amael H.
  • 91
  • 1
  • 4