Jump to content

Recommended Posts

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
Link to comment
https://forums.phpfreaks.com/topic/5318-help-with-if-else-statement/
Share on other sites

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 accordingly

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

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

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
[!--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 help
xtian
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
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 ?
[!--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/mysql
cheers
xtian
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.