Jump to content


Photo

help with if else statement


  • Please log in to reply
6 replies to this topic

#1 xtiancjs

xtiancjs
  • Members
  • PipPipPip
  • Advanced Member
  • 47 posts

Posted 20 March 2006 - 01:13 AM

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

#2 Humpty

Humpty
  • Members
  • PipPipPip
  • Advanced Member
  • 132 posts

Posted 20 March 2006 - 01:46 AM

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.


- Humpty
  #> Where does the light go when it goes out?

#3 kenrbnsn

kenrbnsn
  • Staff Alumni
  • Advanced Member
  • 8,235 posts
  • LocationHillsborough, NJ, USA

Posted 20 March 2006 - 01:49 AM

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

#4 xtiancjs

xtiancjs
  • Members
  • PipPipPip
  • Advanced Member
  • 47 posts

Posted 20 March 2006 - 02:03 AM

[!--quoteo(post=356552:date=Mar 19 2006, 08:49 PM:name=kenrbnsn)--][div class=\'quotetop\']QUOTE(kenrbnsn @ Mar 19 2006, 08:49 PM) View Post[/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

#5 kenrbnsn

kenrbnsn
  • Staff Alumni
  • Advanced Member
  • 8,235 posts
  • LocationHillsborough, NJ, USA

Posted 20 March 2006 - 02:44 AM

It's printing out a number because in your first line you have
<?php echo $num = $row_bprofile['broker_rating']/$row_bprofile['broker_num_votes']; ?>
Remove that "[!--coloro:#FF0000--][span style=\"color:#FF0000\"][!--/coloro--]echo[!--colorc--][/span][!--/colorc--]" and that should get rid of the number.

Ken

#6 Humpty

Humpty
  • Members
  • PipPipPip
  • Advanced Member
  • 132 posts

Posted 21 March 2006 - 02:24 AM

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) View Post[/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 ?
- Humpty
  #> Where does the light go when it goes out?

#7 xtiancjs

xtiancjs
  • Members
  • PipPipPip
  • Advanced Member
  • 47 posts

Posted 21 March 2006 - 02:44 AM

[!--quoteo(post=356565:date=Mar 19 2006, 09:44 PM:name=kenrbnsn)--][div class=\'quotetop\']QUOTE(kenrbnsn @ Mar 19 2006, 09:44 PM) View Post[/div][div class=\'quotemain\'][!--quotec--]
It's printing out a number because in your first line you have
<?php echo $num = $row_bprofile['broker_rating']/$row_bprofile['broker_num_votes']; ?>
Remove that "[!--coloro:#FF0000--][span style=\"color:#FF0000\"][!--/coloro--]echo[!--colorc--][/span][!--/colorc--]" 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




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users