xtiancjs Posted March 20, 2006 Share Posted March 20, 2006 Hi, I need help with the following piece of code, thanks to hitman for steering me in the right direction, basically ,depending on the result of $num i am trying to get the correct image to display, can anybody help to see why my image doesn't display, just the numerical value. [!--coloro:#333399--][span style=\"color:#333399\"][!--/coloro--]<?php echo $num = $row_bprofile['broker_rating']/$row_bprofile['broker_num_votes']; if ($num > 0 && $num <= .5) { echo '<img src="images/0.5_dark.png">';} else if ($num > .5 && $num <= 1) { echo '<img src="images/0.5_dark.png">';} else if ($num > 1 && $num <= 1.5) { echo '<img src="images/0.5_dark.png">';} else if ($num > 1.5 && $num <= 2) { echo '<img src="images/0.5_dark.png">';} else if ($num > 2 && $num <= 2.5) { echo '<img src="images/0.5_dark.png">';} else if ($num > 2.5 && $num <= 3) { echo '<img src="images/0.5_dark.png">';} else if ($num > 3 && $num <= 3.5) { echo '<img src="images/0.5_dark.png">'; }else if ($num > 3.5 && $num <= 4) { echo '<img src="images/0.5_dark.png">'; }else if ($num > 4 && $num <= 4.5) { echo '<img src="images/0.5_dark.png">'; }else { echo '<img src="images/0.5_dark.png">';} ?>[!--colorc--][/span][!--/colorc--]thanks xtian Quote Link to comment https://forums.phpfreaks.com/topic/5318-help-with-if-else-statement/ Share on other sites More sharing options...
Humpty Posted March 20, 2006 Share Posted March 20, 2006 I have no real idea at all. Just some things that I would try> Checking the name (can be case sensitive)> Echo the result without the image tag part just to see it)> Remove the . for 0.5> Place the numbers after the word dark ( dark_05.png) (and rename file accordinglyWhen I need to echo an <img> I will actually copy and paste the code from a known working spot.Other than that I can't say I know the problem.I did read once that when you include a DB connections file you should call it filename.anythingelse.phpbecause that confuses FTPs or HTTP or something else (having the two dots in there. So that would be the 2nd thing i try after checkign that the path and name are correct. Quote Link to comment https://forums.phpfreaks.com/topic/5318-help-with-if-else-statement/#findComment-18936 Share on other sites More sharing options...
kenrbnsn Posted March 20, 2006 Share Posted March 20, 2006 I think you copied you code incorrectly ... you're using the same image nomatter what the value of $num is. Please post the code you really want us to look at.For the previous poster:If the OP is using UNIX or Linux, files can have multiple dots with no problems and can start with numbers.Ken Quote Link to comment https://forums.phpfreaks.com/topic/5318-help-with-if-else-statement/#findComment-18938 Share on other sites More sharing options...
xtiancjs Posted March 20, 2006 Author Share Posted March 20, 2006 [!--quoteo(post=356552:date=Mar 19 2006, 08:49 PM:name=kenrbnsn)--][div class=\'quotetop\']QUOTE(kenrbnsn @ Mar 19 2006, 08:49 PM) [snapback]356552[/snapback][/div][div class=\'quotemain\'][!--quotec--]I think you copied you code incorrectly ... you're using the same image nomatter what the value of $num is. Please post the code you really want us to look at.For the previous poster:If the OP is using UNIX or Linux, files can have multiple dots with no problems and can start with numbers.Ken[/quote]So Sorry, I was staring at that thing for ever, you were right, I did however rename the images in a better way, it now almost works, my problem is now it still shnows the numeric value above the graphic??anyway thanks for your helpxtian Quote Link to comment https://forums.phpfreaks.com/topic/5318-help-with-if-else-statement/#findComment-18945 Share on other sites More sharing options...
kenrbnsn Posted March 20, 2006 Share Posted March 20, 2006 It's printing out a number because in your first line you have [code]<?php echo $num = $row_bprofile['broker_rating']/$row_bprofile['broker_num_votes']; ?>[/code]Remove that "[b][!--coloro:#FF0000--][span style=\"color:#FF0000\"][!--/coloro--]echo[!--colorc--][/span][!--/colorc--][/b]" and that should get rid of the number.Ken Quote Link to comment https://forums.phpfreaks.com/topic/5318-help-with-if-else-statement/#findComment-18951 Share on other sites More sharing options...
Humpty Posted March 21, 2006 Share Posted March 21, 2006 Ken... Very off topic here (sorta)[!--quoteo(post=356552:date=Mar 19 2006, 08:49 PM:name=kenrbnsn)--][div class=\'quotetop\']QUOTE(kenrbnsn @ Mar 19 2006, 08:49 PM) [snapback]356552[/snapback][/div][div class=\'quotemain\'][!--quotec--]For the previous poster:If the OP is using UNIX or Linux, files can have multiple dots with no problems and can start with numbers.Ken[/quote]I'm not arguing because that is what I thought, (i'm a windows user, and have only managed a webserver on my own machine for internal testing).If that is the case then why would someone suggest name the database details file, (e.g. dbd.php) to somethign like dbd.nfi.php ?I that any assistance security wise? or am I mislead and in turn misleading :D ? Quote Link to comment https://forums.phpfreaks.com/topic/5318-help-with-if-else-statement/#findComment-19206 Share on other sites More sharing options...
xtiancjs Posted March 21, 2006 Author Share Posted March 21, 2006 [!--quoteo(post=356565:date=Mar 19 2006, 09:44 PM:name=kenrbnsn)--][div class=\'quotetop\']QUOTE(kenrbnsn @ Mar 19 2006, 09:44 PM) [snapback]356565[/snapback][/div][div class=\'quotemain\'][!--quotec--]It's printing out a number because in your first line you have [code]<?php echo $num = $row_bprofile['broker_rating']/$row_bprofile['broker_num_votes']; ?>[/code]Remove that "[b][!--coloro:#FF0000--][span style=\"color:#FF0000\"][!--/coloro--]echo[!--colorc--][/span][!--/colorc--][/b]" and that should get rid of the number.Ken[/quote]Thanks for all the help there Ken and Co. Everything seems to be working smoothly, will be hammering away again tonight at this beast called php/mysqlcheers xtian Quote Link to comment https://forums.phpfreaks.com/topic/5318-help-with-if-else-statement/#findComment-19210 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.