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:

# 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>&lt;&lt;&nbsp;';

		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 '&nbsp;&gt;&gt;</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>&lt;&lt;&nbsp;';
	#		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 '&nbsp;&gt;&gt;</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.

case statements are followed by a colon, not a semicolon. case '82';{ should be case '82':{ The same goes for the others

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

This question has already been answered. Start a new discussion instead.