Jump to content

getting my else statement to work


contra10

Recommended Posts

i want to have the ability to display a message if the user has allowed only a certain type of people to vote

 

right now my code displays only the message in this case is displaying "...user is only allowing frieds to vote"...I'm testing as a friend and the rating system isn't showing, i checked my database and the user under which i am signed in is a friend of the user i am voting on

 

<?php
	 $query= "SELECT * FROM `users` WHERE `id` = '$id'";
$result = mysql_query($query) or die(mysql_error());;
while($response = mysql_fetch_assoc($result)){

	$usernameop= "{$response['username']}";
	$usercity = "{$response['city']}";
}
 $friendq= "SELECT * FROM friends WHERE username = '$usernameop'";
$friendnames = mysql_query($friendq) or die(mysql_error());

while($friend = mysql_fetch_array($friendnames)) 
{ 
$friendusername= "{$friend['friendname']}";
}
 $query3= "SELECT * FROM `vote_ability` WHERE `username` = '$usernameop'";
$result3 = mysql_query($query3) or die(mysql_error());;
while($response3 = mysql_fetch_assoc($result3)){

	$valueofvoting= "{$response3['value']}";
}
if ($valueofvoting == "allowall"){
echo"<input type='radio' name='rating' value='1' >1"; 
echo"<input type='radio' name='rating' value='2' >2";
echo"<input type='radio' name='rating' value='3' >3"; 
echo"<input type='radio' name='rating' value='4' >4";
echo"<input type='radio' name='rating' value='5' checked>5"; 
echo"<input type='radio' name='rating' value='6' >6";
echo"<input type='radio' name='rating' value='7' >7"; 
echo"<input type='radio' name='rating' value='8' >8";
echo"<input type='radio' name='rating' value='9' >9"; 
echo"<input type='radio' name='rating' value='10' >10";
echo"<input type='hidden' name='idofrate' value='$id'>";
echo "<input type='submit' name='submit' value='rate'>";
}
elseif($valueofvoting == "allowfriends"){
if ($username == $friendusername){
echo"<input type='radio' name='rating' value='1' >1"; 
echo"<input type='radio' name='rating' value='2' >2";
echo"<input type='radio' name='rating' value='3' >3"; 
echo"<input type='radio' name='rating' value='4' >4";
echo"<input type='radio' name='rating' value='5' checked>5"; 
echo"<input type='radio' name='rating' value='6' >6";
echo"<input type='radio' name='rating' value='7' >7"; 
echo"<input type='radio' name='rating' value='8' >8";
echo"<input type='radio' name='rating' value='9' >9"; 
echo"<input type='radio' name='rating' value='10' >10";
echo"<input type='hidden' name='idofrate' value='$id'>";
echo "<input type='submit' name='submit' value='rate'>";
	} else {
	echo "$usernameop is only allowing friends to vote on photos";
	}
	}
echo"</form>";
?>

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.