| | |
Switch Statement output error
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Thread Solved |
Hi again,
This time am outputting some html using a switch statement, but the outputted html code is not acting as coded, seems a very strange error as in both the case statements (first and third) its plain html but the link is just not acting correctly, but the main case (middle one) is working perfectly.
Here is what i have written:
the output of case '0' = tao.php?chapter=0 on both the echo and the print
the output of case '82' = tao.php?chapter=82 even though the link is for a different file within the same directory (on the site root)
Its clearly reading the switch because i made small differences to the code, but i cannot understand why the a href links are not working as coded.
If anyone can shed any light on this i would be very grateful.
This time am outputting some html using a switch statement, but the outputted html code is not acting as coded, seems a very strange error as in both the case statements (first and third) its plain html but the link is just not acting correctly, but the main case (middle one) is working perfectly.
Here is what i have written:
PHP Syntax (Toggle Plain Text)
# Displays Previous and Next line options table # Output HTML with Active Links # Implementing switch-case to output different html based on chapter number. switch($chapter) { case '0';{ print '<table width="685" align="center" cellspacing="1"><tr class="title_colour"><td align="center">table width="100%" border="0" cellspacing="0"><tr class="title_colour"><td><center>'; echo "<a href'tao.php?chapter=$next_chapter'>Take the first step on your journey!</a><br>"; #METHOD 1 print '<a href"tao.php?chapter=1" target="_self">Take the first step on your journey!</a>'; #METHOD 2 print '</center></td></tr></table></td></tr></table>'; } break; case (($chapter >= '1') && ($chapter <= '81'));{ print '<table width="685" align="center" border="0" cellspacing="0"><tr class="title_colour"><td align="center"><center><< '; echo "<a href='tao.php?chapter=$prev_chapter'>Previous Chapter</a>"; print '</center></td><td><center>'; echo "<a href='tao.php?chapter=$next_chapter'>Next Chapter</a>"; print ' >></center></td></tr></table></td></tr></table>'; } break; case '82';{ print '<table width="685" align="center" cellspacing="1"><tr class="title_colour"><td align="center"><table width="100%" border="0" cellspacing="0"><tr class="title_colour"><td><center>'; echo "<a href'homepage.php?view=home'>Take me back to the Homepage</a>"; print '</center></td></tr></table></td></tr></table>'; } break; #default: # { # print '<table width="685" align="center" border="0" cellspacing="0"><tr class="title_colour"> # <td align="center"><center><< '; # echo "<a href='tao.php?chapter=$prev_chapter'>Previous Chapter</a>"; # print '</center></td><td><center>'; # echo "<a href='tao.php?chapter=$next_chapter'>Next Chapter</a>"; # print ' >></center></td></tr></table></td></tr></table>'; # } # break; } # End of Switch
the output of case '0' = tao.php?chapter=0 on both the echo and the print
the output of case '82' = tao.php?chapter=82 even though the link is for a different file within the same directory (on the site root)
Its clearly reading the switch because i made small differences to the code, but i cannot understand why the a href links are not working as coded.
If anyone can shed any light on this i would be very grateful.
Last edited by DaitoTsu; Dec 7th, 2007 at 11:31 am.
The world is in chaos, the only true order can be found in : "48657861646563696D616C00" ;)
-Daito
-Daito
case statements are followed by a colon, not a semicolon.
case '82';{ should be case '82':{ The same goes for the others GCS d- s+ a-->? C++(++++) UL+++ P+>+++ L+++ E--- W+++
N+ o K w++(---) O? !M- V PS+>++ PE+ Y+ PGP !t- 5? X- R tv+
b+>++ DI+ D G++>+++ e+ h+>++ r y+
PMs asking for help will not be answered, post on the forums. That's what they're there for.
N+ o K w++(---) O? !M- V PS+>++ PE+ Y+ PGP !t- 5? X- R tv+
b+>++ DI+ D G++>+++ e+ h+>++ r y+
PMs asking for help will not be answered, post on the forums. That's what they're there for.
Thanks for that Shawn, made the changes didnt help me but i did finally find the problem.
*ahem* i missed '=' in the a href links in the 2 html outputs that didnt work and thats why it was loopin back on itself.
Moderator / Admin feel free to delete this post i dont think it'll be helpful to anyone else, since it was a silly little error.
$dsylexia + $booze != $good_coding
lol
Take care folks
*ahem* i missed '=' in the a href links in the 2 html outputs that didnt work and thats why it was loopin back on itself.
Moderator / Admin feel free to delete this post i dont think it'll be helpful to anyone else, since it was a silly little error.
$dsylexia + $booze != $good_coding
lolTake care folks
The world is in chaos, the only true order can be found in : "48657861646563696D616C00" ;)
-Daito
-Daito
![]() |
Similar Threads
- helllp with loops (C++)
- Segmentation Fault (C++)
- C++ question on classes (C++)
- Playing cards (C++)
- Problems with switch statement (C++)
- program w/ switch AND nested if. six error messages (C++)
- Need some help with my do-while and while loops (Java)
Other Threads in the PHP Forum
- Previous Thread: How do I build a consent form?
- Next Thread: Error handling
| Thread Tools | Search this Thread |
Tag cloud for PHP
.htaccess 301 access ajax apache api array beginner binary broken cakephp checkbox class cms code compression cron curl database date directory display download dropdown dynamic echo email error file files folder form forms function functions google href htaccess html httppost image include insert integration ip java javascript joomla limit link login loop mail md5 menu methods mlm mod_rewrite multiple mysql oop parse paypal pdf php problem query radio random recursion regex remote script search secure select server sessions sms soap source space speed sql structure syntax system table tutorial update upload url validation validator variable video votedown web xml youtube






