Switch Statement output error

Thread Solved

Join Date: Dec 2007
Posts: 19
Reputation: DaitoTsu is an unknown quantity at this point 
Solved Threads: 1
DaitoTsu's Avatar
DaitoTsu DaitoTsu is offline Offline
Newbie Poster

Switch Statement output error

 
0
  #1
Dec 7th, 2007
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:

  1. # Displays Previous and Next line options table
  2. # Output HTML with Active Links
  3. # Implementing switch-case to output different html based on chapter number.
  4.  
  5. switch($chapter)
  6. {
  7. case '0';{
  8. 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>';
  9.  
  10. echo "<a href'tao.php?chapter=$next_chapter'>Take the first step on your journey!</a><br>"; #METHOD 1
  11.  
  12. print '<a href"tao.php?chapter=1" target="_self">Take the first step on your journey!</a>'; #METHOD 2
  13.  
  14. print '</center></td></tr></table></td></tr></table>';
  15. }
  16. break;
  17.  
  18. case (($chapter >= '1') && ($chapter <= '81'));{
  19. print '<table width="685" align="center" border="0" cellspacing="0"><tr class="title_colour"><td align="center"><center>&lt;&lt;&nbsp;';
  20.  
  21. echo "<a href='tao.php?chapter=$prev_chapter'>Previous Chapter</a>";
  22.  
  23. print '</center></td><td><center>';
  24.  
  25. echo "<a href='tao.php?chapter=$next_chapter'>Next Chapter</a>";
  26.  
  27. print '&nbsp;&gt;&gt;</center></td></tr></table></td></tr></table>';
  28. }
  29. break;
  30.  
  31. case '82';{
  32. 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>';
  33.  
  34. echo "<a href'homepage.php?view=home'>Take me back to the Homepage</a>";
  35. print '</center></td></tr></table></td></tr></table>';
  36. }
  37. break;
  38.  
  39. #default:
  40. # {
  41. # print '<table width="685" align="center" border="0" cellspacing="0"><tr class="title_colour">
  42. # <td align="center"><center>&lt;&lt;&nbsp;';
  43. # echo "<a href='tao.php?chapter=$prev_chapter'>Previous Chapter</a>";
  44. # print '</center></td><td><center>';
  45. # echo "<a href='tao.php?chapter=$next_chapter'>Next Chapter</a>";
  46. # print '&nbsp;&gt;&gt;</center></td></tr></table></td></tr></table>';
  47. # }
  48. # break;
  49. } # 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
Reply With Quote Quick reply to this message  
Join Date: Apr 2005
Posts: 1,426
Reputation: ShawnCplus is a glorious beacon of light ShawnCplus is a glorious beacon of light ShawnCplus is a glorious beacon of light ShawnCplus is a glorious beacon of light ShawnCplus is a glorious beacon of light ShawnCplus is a glorious beacon of light 
Solved Threads: 230
Sponsor
ShawnCplus's Avatar
ShawnCplus ShawnCplus is offline Offline
Code Monkey

Re: Switch Statement output error

 
0
  #2
Dec 8th, 2007
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.
Reply With Quote Quick reply to this message  
Join Date: Dec 2007
Posts: 19
Reputation: DaitoTsu is an unknown quantity at this point 
Solved Threads: 1
DaitoTsu's Avatar
DaitoTsu DaitoTsu is offline Offline
Newbie Poster

Re: Switch Statement output error

 
0
  #3
Dec 9th, 2007
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
The world is in chaos, the only true order can be found in : "48657861646563696D616C00" ;)

-Daito
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



Tag cloud for PHP
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC