![]() |
Switch Command Problems
Before I ask my question, let me say that I am an old dbase programmer (and I do mean (OLD!) so, while I am not a absolute beginner, PHP is another languange (though the syntax is somewhat related).
Here is what I want to do: Without using frames I want to use the switch command to replace the majority of the screen on a rotating basis. Several years ago (maybe 4 or 5) I had the switch command working like this but some idiot newbie programmer at the webhost overwrote it and I didn't have it backed up. If you go to www.stevenwjohnson.com you will see what I have now. What I want to do is add a left hand menu (easy enough to do in HTML) and have each individual book display on the majority of the page, incrementing the variable +1 for every view so people don't see the same book every time they visit the site. And every refresh will bring up a new book. My problem is that for every 'sample' switch/case code I download I get nothing but the logo and the top and bottom menus. Here is the code I have been playing with... <?php switch ($x) { case 0: echo "x equals 0"; break; case 1: echo "x equals 1"; break; case 2: echo "x equals 2"; break; default: echo "x is not equal to 0, 1 or 2"; } ?> I realize somewhere I should increment x but I can't even get the default to echo. HELP!!! Seal |
Ok, so you want to have a different layout and you only want to show 1 book and when they refresh the page you show another book, randomly. I don't think refreshing is a good way to navigate through the books if anything I would say instead of displaying 1, display them all downwards and just select randomly which is going to be at the top. Or am I understanding it badly?
About the switch code you posted, I tried it out and it work for me: php Code:
I am wondering if the way you get the value of $x returns you a string because a string in a loose comparison (which is what the switch statement does) would be equal to 0. P.S. It would be better if you are sharing code to wrap it in highlight tags. |
| All times are GMT. The time now is 03:55 AM. |
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0