Reviews, updates and in depth guides to your favourite mobile games - AppGamer.com
|
|
having trouble with page.php?id=index stuff |
Page: 1 | Reply |
Dec 13th 2003 | #133230 Report |
Member since: Mar 29th 2003 Posts: 1326 |
What do I make the href=" " on the < a > for for this to work? I understand how the switch-case thing works, but I don't understand how it works with the $_GET superglobal, so I would appreciate an explanation of that, too. Oh and I added the CSS because I'm having a little problem with link colors (on the footer) but I'll get that worked out before long I think. Here's the code: [PHP] include('header.inc.php'); $id = $_GET['id']; switch ($id) { case 'index': include('index.inc.php'); break; case 'journals': include('journals.inc.php'); break; case 'presentations': include('presentations.inc.php'); break; case 'pictures': include('pictures.inc.php'); break; case 'programinfo': include('programinfo.inc.php'); break; case 'links': include('links.inc.php'); break; default: include('index.inc.php'); } include('footer.inc.php'); ?> [/PHP] Thanks for your help. tom |
Reply with Quote Reply |
Dec 13th 2003 | #133239 Report |
Member since: Nov 26th 2001 Posts: 2586 |
index.php?id=links for example. If you have this same type of code with sub pages (like maybe on the links page you have more of something like linkid or something like that you would use: index.php?id=links&linkid=23 for example. Your index page is basically a 'wrapper' for your site. |
Reply with Quote Reply |
Dec 13th 2003 | #133240 Report |
Member since: Mar 29th 2003 Posts: 1326 |
So I go [PHP]presentations[/PHP]? I don't really understand that ... but I guess I'll use it anyways. tom |
Reply with Quote Reply |
Dec 13th 2003 | #133241 Report |
Member since: May 22nd 2003 Posts: 315 |
$_REQUEST[];
|
Reply with Quote Reply |
Dec 13th 2003 | #133243 Report |
Member since: Nov 26th 2001 Posts: 2586 |
[QUOTE]Originally posted by Doolittle [B]$_REQUEST[]; [/B][/QUOTE] Nope - use GET.... and that is right trhaynes - and no I am not drunk! lol.... and add some code above $id = $_GET['']; like this: [php] if ( !isset ($id) ) { $id = 'index'; } [/php] There will be an error that you may not see depending on what your error level is set to. and is the page you are showing - with the switch, is that index.php? |
Reply with Quote Reply |
Dec 14th 2003 | #133246 Report |
Member since: Mar 29th 2003 Posts: 1326 |
lmao- When I saw your post, I asked doolittle about it on AIM and he explained it to me and exactly how it works. Then I realized that I should probably edit my "are you drunk?" post. But you saw it anyways. The if (!isset) {} is a good idea - makes perfect sense. And yes, the page is index.php. http://trhaynes.commscentral.net:8000/cuba2/index.php Thanks. tom |
Reply with Quote Reply |
Dec 14th 2003 | #133250 Report |
Member since: Nov 26th 2001 Posts: 2586 |
$_REQUEST will work, but it's not needed. It's just get, post, and file all shoved into one array. The isset just checks to see if id has a value to it. But when you go to your site, like www.yoursite.com id does not have a value yet and there is an error occuring. But a good idea is create some config file that you can include, and on that file you can set the error warning level - good for debugging. You can turn it on or off this way: [php] /* Error handling level: */ error_reporting (E_ALL); // --> best for debugging. //error_reporting (E_ALL ^ E_NOTICE); // default //error_reporting (E_ERROR | E_WARNING | E_PARSE | E_NOTICE); //error_reporting(0); // error reporting turned off. //error_reporting (E_ERROR | E_WARNING | E_PARSE); // basic error reporting. [/php] Then once the site is up and working, you can turn off error messages. So you'll see a blank page rather than an ugly php error message displaying your directory. |
Reply with Quote Reply |
Page: 1 | Back to top |
Please login or register above to post in this forum |
© Web Media Network Limited. All rights reserved. No part of this website may be reproduced without written permission. Photoshop is a registered trademark of Adobe Inc.. TeamPhotoshop.com is not associated in any way with Adobe, nor is an offical Photoshop website. |