Jump to content

Not showing the "else" info


colleyboy

Recommended Posts

I have an if statement:

 


// if they are logged in


$aretheyliked = mysql_query("SELECT * FROM boom_likes WHERE user_id=$loggedinuserid");

while($row = mysql_fetch_array($aretheyliked))
  {

if (($row['liked_user_id']==$profileuserid)&&($row['user_id']==$loggedinuserid)){
echo "<FONT SIZE=1 COLOR=BLUE>You Like This Artist";

}
else
{
echo "<FONT SIZE=2 COLOR=BLUE>Like";
}

 

The idea is if the user is logged in they can click the "like".  If they already like it it will say they already do like it.    The else is not showing though.  What am I doing wrong... it works when it matches but not when it dont :(

Link to comment
Share on other sites

I don't see anything syntactically wrong. Is it showing up in the page source? Maybe you have malformed HTML somewhere (speaking of which, you need to close those two font tags (actually you should really be using CSS instead of font tags, but I digress)).

 

Also, this &&($row['user_id']==$loggedinuserid) is unnecessary since you are only selecting rows with that user id to start with.

Link to comment
Share on other sites

Hello,

 

I have gave you an extended snippet of the code and removed the && as I see I reference it twice (good spot :P).

 

The <FONT> tags are temp until I sort the code then I will cleanup with some CSS :P.

 

<!-- LIKE BUTTON -->


<?php

if (isset($_SESSION['useridkey'])){

//check user id in url matches useridkey

if ($_SESSION['useridkey']==$the_user_id){

// the following if the session id matches the variable

//edit profile page

echo "sessionid matches the user id variable";

}

$loggedinuserid = $_SESSION['useridkey'];

// if they are logged in


$aretheyliked = mysql_query("SELECT * FROM boom_likes WHERE user_id=$loggedinuserid");

while($row = mysql_fetch_array($aretheyliked))
  {

//if they are liked by the user

if (($row['liked_user_id']==$profileuserid))){

echo "<FONT SIZE=1 COLOR=BLUE>You Like This Artist";

}
else
{
echo "Like";
}



}




// end of if they are logged in

}
else
{

// if they are not logged in

echo "<FONT SIZE=1 COLOR=RED>You must be logged in to like this artist";

}

?>


<!-- END OF LIKE BUTTON -->

Link to comment
Share on other sites

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.