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
https://forums.phpfreaks.com/topic/145836-getting-my-else-statement-to-work/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.