![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Programmer
Join Date: Jun 2005
Location: Queensland
Posts: 37
Rep Power: 0
![]() |
Multiple IF statements, perhaps?
Hi, what ive done is made a football points table using PHP, that works out games played, percentages, point differences, etc. that is all done properly but now I want to add pictures etc.
I have a drop box with all the team names (Lions, Crows…) that posts to the next page of the currently 2 page program. The team names ($teams on page 2) parse thru and whatever team was selected is printed. What I want is the corresponding team logos to print depending on what team was selected in the drop box (16 teams). The code I originally tried (but obviously didn’t work) was: if ($team = "Adelaide Crows") {
print ("<TR><TD>
<IMG SRC='teams\crows.gif'></TD></TR>");
elseif ($team = "Brisbane Lions") {
print ("<TR><TD>
<IMG SRC='teams\lions.gif'></TD></TR>");
}what happens when I run this is no matter what team I select whether it be lions, crows or another team, it prints the Crows logo, even though it prints the correct team name. What can I do to get around this? Do I need to use multiple if statements? The solution would be greatly appreciated. |
|
|
|
|
|
#2 |
|
Programmer
Join Date: Jun 2005
Location: |\|[][]B |_4|\|D
Posts: 41
Rep Power: 0
![]() |
you could make the $team = the address of the file you are trying to print then give the command
print (<tr><td><img src=teams\$team></td></tr>); please let me know if the solution works and be warned i'm not sure if it will also i don't know how to get it to put $team in as Adelaide Crows but if you look up the syntax i know its possible. good luck |
|
|
|
|
|
#3 |
|
Programmer
Join Date: Jun 2005
Location: Queensland
Posts: 37
Rep Power: 0
![]() |
same problem
hey falsedragon, thanks for the info, but the same problem occurred. i made a variable $crows and made it the img src. i tested it and it printed the logo, so i was ecstatic. then i did added a $lions as the lions logo. so then i did an elseif statement under the crows if statement. tried it out with the lions in the drop menu, and what happened? the same thing again. it is somehting to do with the if statement. there must be a way to include both and all images in one statement. perhaps an or function if it exists.
thanks anyway. regards |
|
|
|
|
|
#4 |
|
Programmer
Join Date: Jun 2005
Location: |\|[][]B |_4|\|D
Posts: 41
Rep Power: 0
![]() |
do you have msn so i could try to help you there?
i am da_devestator2001@yahoo.com (msn) add me and i'll help you fix it. plus it will be just 2 lines long Last edited by TheFalseDragon; Jun 22nd, 2005 at 12:40 AM. Reason: Adding my MSN |
|
|
|
|
|
#5 |
|
Programmer
Join Date: Jun 2005
Location: Queensland
Posts: 37
Rep Power: 0
![]() |
i just came out of my brain death and i thought "maybe a switch statement would work". do u think it could work? heres what ive tried.
switch ($team){
case ($team = "Adelaide Crows"):
echo ("<TR><TD><IMG SRC = 'teams\crows.gif'></TR></TD>");switch ($team){
case ($team = "Adelaide Crows"):
echo ("<TR><TD><IMG SRC = 'teams\crows.gif'></TR></TD>");
break:
case ($team = "Brisbane Lions"):
echo ("<TR><TD><IMG SRC = 'teams\lions.gif'></TR></TD>");
etc.is there a way i can make this switch statement work like this? any input from anyone is very welcome. thanks |
|
|
|
|
|
#6 |
|
Programmer
Join Date: Jun 2005
Location: Queensland
Posts: 37
Rep Power: 0
![]() |
hi falsedragon, MAJOR BREAKTHRU. as i said before i was trying switch statements. IT WORKED. heres a snippet of a successful code:
switch ($team){
case ($team="Adelaide Crows"):
echo ("<TR><TD><IMG SRC = 'teams\crows.gif'></TR></TD>");
break;
case ($team="Brisbane Lions"):
echo ("<TR><TD><IMG SRC = 'teams\lions.gif'></TR></TD>");
}it actually prints the team logo that corresponds with the team name! thanks for your help! |
|
|
|
|
|
#7 |
|
I eat cake for breakfast.
![]() ![]() ![]() ![]() Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9
![]() |
The problem in the original code was that the if block was missing a closing }. Watch out for these things.
|
|
|
|
|
|
#8 |
|
Professional Programmer
|
switch ($team){
case ($team="Adelaide Crows")while(a=10){ .... }while(a==10){ .... }-Dizz |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|