0

Hi, i have written a section of code for my website and i have been trying to get it to work but whatever i try it will not work

Here is the code

$upgrade_user = mysql_query("SELECT * FROM user_info WHERE id='$id'");
while($row = mysql_fetch_array($upgrade_user)){
	$real_balance = $row["$balance"];
	$real_rank = $row["$rank"];
}

echo $real_balance;

if($real_rank == 'merchant' && $real_balance > '500'){
	$n1x = '<a href="upgrades_info.php?userid=$id&rank=noble"><img src="images/noble.jpg" width="170" height="200" /></a>';
}
else
{
	$n1x = '<img src="images/noblex.jpg" width="170" height="200" />';
}

It should outbut the first if, but instead it keeps displaying the else, i have checked the $real_rank and it matches merchant and the $real_balance is over 500.

Any ideas?

I am guessing its a simple error in the way i have written it, but i can't seem to get it to work.

Thanks

Edited by kaosjon: n/a

3
Contributors
2
Replies
3
Views
5 Years
Discussion Span
Last Post by cwarn23
0

It could be as simple as a blank in one of the fields. I suggest that you do the two compares separately (one after the other) and see which one fails. For the one that is failing, look very carefully at the data. You might want to use PHPMyAdmin to inspect the database fields.

0

Do you mean this?

$upgrade_user = mysql_query("SELECT * FROM user_info WHERE id='$id'");
while($row = mysql_fetch_array($upgrade_user)){
	$real_balance = $row["$balance"];
	$real_rank = $row["$rank"];

echo $real_balance;

if($real_rank == 'merchant' && $real_balance > 500){
	$n1x = '<a href="upgrades_info.php?userid=$id&rank=noble"><img src="images/noble.jpg" width="170" height="200" /></a>';
}
else
{
	$n1x = '<img src="images/noblex.jpg" width="170" height="200" />';
}

}

Or this?

$upgrade_user = mysql_query("SELECT * FROM user_info WHERE id='$id'");
$row = mysql_fetch_array($upgrade_user);
$real_balance = $row["$balance"];
$real_rank = $row["$rank"];


echo $real_balance;

if($real_rank == 'merchant' && $real_balance > 500){
	$n1x = '<a href="upgrades_info.php?userid=$id&rank=noble"><img src="images/noble.jpg" width="170" height="200" /></a>';
}
else
{
	$n1x = '<img src="images/noblex.jpg" width="170" height="200" />';
}
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.