SirChick Posted August 15, 2007 Share Posted August 15, 2007 If i have an echo which can change.. which i currently have this: <font style="font-size:16px" color="#FFFFFF" face="Arial"><b><u><?= $ResultQuote ?></u></b></font></div> How do i change it so that the colour will change depending on the what the $ResultQuote is? Quote Link to comment Share on other sites More sharing options...
nathanmaxsonadil Posted August 15, 2007 Share Posted August 15, 2007 if($ResultQuote = '$100') { echo '<font style="font-size:16px" color="green" face="Arial">'; echo $ResultQuote; echo '</font></div>'; }else if($ResultQuote = '$200') { echo '<font style="font-size:16px" color="yellow" face="Arial">'; echo $ResultQuote; echo '</font></div>'; }else if($ResultQuote = '$300') { echo '<font style="font-size:16px" color="red" face="Arial">'; echo $ResultQuote; echo '</font></div>'; } Quote Link to comment Share on other sites More sharing options...
nathanmaxsonadil Posted August 15, 2007 Share Posted August 15, 2007 sorry the code I posted does not work Quote Link to comment Share on other sites More sharing options...
Daniel0 Posted August 15, 2007 Share Posted August 15, 2007 Change if($ResultQuote = '$100') to if($ResultQuote == '$100') (the rest of the places too). = is an assignment operator == is a comparison operator Quote Link to comment Share on other sites More sharing options...
nathanmaxsonadil Posted August 15, 2007 Share Posted August 15, 2007 lol I just figured that out Quote Link to comment Share on other sites More sharing options...
SirChick Posted August 15, 2007 Author Share Posted August 15, 2007 aye i was just about to say lol! But can you do it with captions? <? if($ResultQuote == 'Result: You search the train station from top to bottom and find $1!') { echo '<font style="font-size:16px" color="green" face="Arial">'; echo $ResultQuote; echo '</font></div>'; }else if($ResultQuote == 'You failed to find any money, better try some other time!') { echo '<font style="font-size:16px" color="red" face="Arial">'; echo $ResultQuote; echo '</font></div>'; }else if($ResultQuote == 'Result: You search the train station from top to bottom and find $3!') { echo '<font style="font-size:16px" color="green" face="Arial">'; echo $ResultQuote; echo '</font></div>'; }else if($ResultQuote == 'Result: You search the train station from top to bottom and find $5!') { echo '<font style="font-size:16px" color="green" face="Arial">'; echo $ResultQuote; echo '</font></div>'; } ?> this is what i put.. but it just displays nothing.. ? the $ResultQuote is created in an include else where... just encase you wondered why i compare them to strings Quote Link to comment Share on other sites More sharing options...
Daniel0 Posted August 15, 2007 Share Posted August 15, 2007 Before the if statements, try to echo $ResultQuote to see what it actually is. Quote Link to comment Share on other sites More sharing options...
nathanmaxsonadil Posted August 15, 2007 Share Posted August 15, 2007 it works for me Quote Link to comment Share on other sites More sharing options...
SirChick Posted August 15, 2007 Author Share Posted August 15, 2007 hmm it doesnt echo it. good spot. gah that is rediculously annoying lol so many lines to look through *cries* lol would any one care to take a look ? i cant post it here though way too much to post and im not comfortable posting my work too everyone :/ Quote Link to comment Share on other sites More sharing options...
nathanmaxsonadil Posted August 15, 2007 Share Posted August 15, 2007 change else if($ResultQuote == 'Result: You search the train station from top to bottom and find $5!') { echo '<font style="font-size:16px" color="green" face="Arial">'; echo $ResultQuote; echo '</font></div>'; } to else if($ResultQuote == 'Result: You search the train station from top to bottom and find $5!') { echo '<font style="font-size:16px" color="green" face="Arial">'; echo $ResultQuote; echo '</font></div>'; }else { echo 'none of those'; echo $ResultQuote; } Quote Link to comment Share on other sites More sharing options...
SirChick Posted August 15, 2007 Author Share Posted August 15, 2007 "none of those" came out. so that means its not writing to the variable properly in my other scripts then. Quote Link to comment Share on other sites More sharing options...
nathanmaxsonadil Posted August 15, 2007 Share Posted August 15, 2007 even if your $varible was not defined the last else would still come out strange Quote Link to comment Share on other sites More sharing options...
SirChick Posted August 15, 2007 Author Share Posted August 15, 2007 no cos if my $variable was blank it would go to the else if which would then : echo 'none of those'; Quote Link to comment Share on other sites More sharing options...
SirChick Posted August 15, 2007 Author Share Posted August 15, 2007 i found my error its to do with this: if ($EXP <= 300) AND ($EXP > 100) can you see whats wrong with it ? this is the error: Parse error: syntax error, unexpected T_LOGICAL_AND in C:\xampp\htdocs\UnderBridgeCrimeScript.php on line 30 Quote Link to comment Share on other sites More sharing options...
Daniel0 Posted August 16, 2007 Share Posted August 16, 2007 if (($EXP <= 300) AND ($EXP > 100))[code] [/code] Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.