Hi All
I'm using a PHP switch routine to choose which text is used on a page, depending on which link is pressed prior to the page opening (the link passes the case number via the URL).
It works well, except, it echos/prints the case name of the text after the text also!
So:
$txt=$_GET[txt]; switch ($txt) { case "1" : echo "Test1."; break; case "2" : echo "Test2."; break; case "3" : echo "Test3."; break; }
Then further down the page in the html:
<p><?php echo $txt ?></p>
This will result in something like this being displayed on the page:
Test1.
1
So the case number 1 is being displayed! :?
I understand (perhaps) why it's doing it, but, being a PHP person only when necessary, my knowledge of a fix is limited (or, time better spent elsewhere!)
Any ideas?
PHP Switch help
Okay, case solved... I put the switch PHP statement in the wrong place. It needed to be located actually where it was going to print the results in the page (as opposed to before the HTML).
Case dismissed. =D>
PHP Switch help
As I only started to try and understand the "switch" routine yesterday,
am so glad you managed to solve it
But of course I've now got to go over it again as your questions made me realise I am less than ofay with it :roll:
Ta!
PHP Switch help
I was never at ease with it until I actually had something to use it for... then the jigsaw sorta fitted together.
PHP Switch help
This is often the problem, I find I'm trying to understand something whilst not actualy using it in a practical example; never works, as you say you need to be actually using it then the penny drops :roll: