Jump to content
MakeWebGames

Recommended Posts

Posted

This is probably really easy, but I just can't find out how to work it:

I would like it so that when a person attempts to buy a house they can't afford, it says how much more money they need to get the house....I have this:

 

{$np['hPRICE']} - {$ir['money']}

 

But that only outputs the house price minus the users money...but not the final answer. This also doesn't work:

 

({$np['hPRICE']} - {$ir['money']})

 

I thought I would need the ( and ), but no....

Can anyone help me...please. :-P

Cheers,

The Ace

Posted

Re: Slight Problem

What?

House price: 100

User money: 80

100 - 80 = 20 ~ how much more they need

How isn't that right?

Unless you mean it just shows "You need 100 - 80", then do it outside of the string:

 

$need = number_format($np['hPRICE'] - $ir['money']);
echo 'You need $' . $need . ' to buy the house';
Posted

Re: Slight Problem

Grr...I get this: Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /usr/home/*****/domains/***/public_html/newestate2.php on line 17

Here are my lines above and below the parse error:

 

else if ($np['hPRICE'] > $ir['money'])
{
print "You do not have enough money to buy the {$np['hNAME']} for £{$np['hPRICE']}. 
$need = number_format($np['hPRICE'] - $ir['money']);
echo 'You need £' . $need . ' more to buy this house.'";

 

This is line 17:

 

$need = number_format($np['hPRICE'] - $ir['money']);

 

Thanks for helping me!

 

Unless you mean it just shows "You need 100 - 80",

Yes...I did mean that! :-P lol.

Posted

Re: Slight Problem

 

else if ($np['hPRICE'] > $ir['money'])
{
print "You do not have enough money to buy the {$np['hNAME']} for £{$np['hPRICE']}";
$need = number_format($np['hPRICE'] - $ir['money']);
echo 'You need £' . $need . ' more to buy this house.';

 

You have to remember/learn where strings break, what is a string, what a string can do/contain, how its parsed

Posted

Re: Slight Problem

Thank you very much! Works perfectly!

How do I get this: You do not have enough money to buy the White Hole for £1.5e+10. You need £14,999,800,000 more to buy this house.

to display: £15,000,000,000? Do I add a number_format after the £ sign and before {$np['hPRICE']}. ";

Thanks again! :D

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.   Paste as plain text instead

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