Jump to content

Recommended Posts

For some reason its showing the first td with the image and it shouldnt' be the first td has a userID value of 10000.

 

<?php
echo "<td>";
                    echo $row['userID'];
                    if (($row['userID'] !== 10000) || ($row['userID'] !== $userID)) {
                        echo "<a href=\"#\" class=\"ask\"><img src=\"images/trash.png\" class=\"delete\" alt=\"\" title=\"\" border=\"0\" id=\"".$row['userID']."\" /></a>";
                    }
                    echo "</td>";
?>

Link to comment
https://forums.phpfreaks.com/topic/240956-shouldnt-be-showing-image/
Share on other sites

<?php
echo "<td>";
                    echo $row['userID'];
                    if ($row['userID'] != 10000 || $row['userID'] != $userID) {
                        echo "showing";
                    }
                    echo "</td>";
?>

Wait, maybe this should be an AND for logic?

Want to make sure it's their user id, but not 10000

 

<?php
echo "<td>";
                    echo $row['userID'];
                    if ($row['userID'] != 10000 && $row['userID'] == $userID) {
                        echo "<a href=\"#\" class=\"ask\"><img src=\"images/trash.png\" class=\"delete\" alt=\"\" title=\"\" border=\"0\" id=\"".$row['userID']."\" /></a>";
                    }
                    echo "</td>";
?>

I can understand why you would think that but the purpose of that if is for it to see if its the 10000 aka non deletable user or that the $row['userID'] is the same as the current logged in user meaning they can't delete themselves if they are logged in.

<?php
echo "<td>";
                    echo $row['userID'];
                    if ($row['userID'] != 10000 && $row['userID'] != $userID) {
                        echo "<a href=\"#\" class=\"ask\"><img src=\"images/trash.png\" class=\"delete\" alt=\"\" title=\"\" border=\"0\" id=\"".$row['userID']."\" /></a>";
                    }
                    echo "</td>";
?>

if user not 10000 OR user not equal to user

echo result in either condition

 

if user not 10000 AND user not equal to user

echo result if both conditions are met

 

so if you do OR and user is user it would always show image even if userid is 10000

Read the full statement to yourself and it should make sense.

 

if($row['userID'] != 10000 && $row['userID'] != $userID)

IF

$row doesn't equal 10000

AND

$row doesn't equal $userID

 

 

The other way:

($row['userID'] != 10000 || $row['userID'] != $userID)

IF

$row doesn't equal 10000

OR

$row doesn't equal $userID

 

It does NOT read

If $row doesn't equal 10000 OR $userID

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.