Jump to content

[SOLVED] Wrong value being echo'd when echoing all users money


MasterACE14

Recommended Posts

Morning Everyone,

 

I have a script which I use to simply echo every users information into a table. That works fine. The problem I am having is I want to either display(for there money column in database) ?? or there actual money, depending on what your Covert Action is. So if they have a higher covert action then you do. Then it should display ?? in the table under money. But for some reason, it is just displaying there money, whether or not there covert is higher then yours.

 

Any help is greatly appreciated like always  :)

 

<?php
// Relevent code only

while ($a_row = mysql_fetch_assoc( $result ) ) {

	$all_id = stripslashes($a_row['id']);
	$all_name = stripslashes($a_row['username']);
	$all_rank = stripslashes($a_row['rank']);
	$all_race = stripslashes($a_row['race']);
	$all_money = stripslashes($a_row['money']);

if($player_covertaction >= $other_player_covertaction) {		
// can you see their money?
$all_player_real_money = "$".number_format($all_money);
}
else {
$all_player_real_money = "???";
}

// I then echo $all_player_real_money; in the table

?>

 

Regards ACE

Link to comment
Share on other sites

Thankyou Heaps rarebit, you just pointed out my problem, and the script now works fine!

 

$other_player_covertaction didn't exist. and I needed the covertaction of every player.

 

So here is my new working script:

<?php
while ($a_row = mysql_fetch_assoc( $result ) ) {

	$all_id = stripslashes($a_row['id']);
	$all_name = stripslashes($a_row['username']);
	$all_rank = stripslashes($a_row['rank']);
	$all_race = stripslashes($a_row['race']);
	$all_money = stripslashes($a_row['money']);
	$all_covertaction = stripslashes($a_row['covertaction']);

if($player_covertaction >= $all_covertaction) {		
// can you see their money?
$all_player_real_money = "$".number_format($all_money);
}
else {
$all_player_real_money = "???";
}		

?>

 

added $all_covertaction to grab all users covert action. which is then used in the if.

 

Thanks again.  ;D

 

Regards ACE

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.