BrianM Posted June 11, 2008 Share Posted June 11, 2008 How is it that you get one page, say index.php, to contain content for multiple pages. Like - index.php?mode=register or index.php?mode=edit ... that being an example, I hope somebody see's what I'm getting at here. But how does a page use $_GET[''] based on the contents of the query string to determine what part of a page to display if it's all on one page? Link to comment https://forums.phpfreaks.com/topic/109695-query-string-question/ Share on other sites More sharing options...
grimmier Posted June 11, 2008 Share Posted June 11, 2008 when you use $_GET['variablename'] it retrieves the value for you from the URL. so as in your example: the URL = index.php?mode=register $a = $_GET['mode']; //print($a); Now you use that variable in a switch statement and use it to call your includes. switch $a { case "register": include('register.php'); break; case "edit": include('edit.php'); break; case default: include('main.php'); break; } you would setup all these pages to be the content of your site. and put the above code at the top of your page. Link to comment https://forums.phpfreaks.com/topic/109695-query-string-question/#findComment-562889 Share on other sites More sharing options...
BrianM Posted June 11, 2008 Author Share Posted June 11, 2008 Ah, makes sense. Thank you very much, and for the ex. as well! Link to comment https://forums.phpfreaks.com/topic/109695-query-string-question/#findComment-562895 Share on other sites More sharing options...
BrianM Posted June 11, 2008 Author Share Posted June 11, 2008 Instead of making a new topic I thought I would continue in this one. I'm getting this error with the following code, and I don't see any problem with it, hopefully somebody else will. Error: Parse error: parse error, expecting `'('' in C:\Program Files\Apache Group\Apache2\htdocs\timetech\install.php on line 110 Code: <?php mysql_close($mysql_connect) or die(mysql_error()); } else if { // this is line 110 header("Location: install.php?mode=delete"); } ?> Link to comment https://forums.phpfreaks.com/topic/109695-query-string-question/#findComment-562904 Share on other sites More sharing options...
cocoras Posted June 11, 2008 Share Posted June 11, 2008 if (isset($_GET['p'])){ if (valalpha($_GET['p'],1,255) AND (file_exists("ing/". $_GET['p'] . ".php"))){include("ing/". $_GET['p'] . ".php");} else{include("ing/news.php");} } ELSE { include("ing/news.php"); } im using this script for that... Link to comment https://forums.phpfreaks.com/topic/109695-query-string-question/#findComment-562908 Share on other sites More sharing options...
BrianM Posted June 11, 2008 Author Share Posted June 11, 2008 grimmier, your get example works, but I don't want it to keep the same page content up after a new query string is brought up, but instead take away what's there and just show the new include file without the old page... is this possible? Link to comment https://forums.phpfreaks.com/topic/109695-query-string-question/#findComment-562914 Share on other sites More sharing options...
grimmier Posted June 11, 2008 Share Posted June 11, 2008 yeah you can do that, just recall the page and change your variables witin the url. if you want to keep the same function for all of your pages. i have some other examples of this floating around. but its 3:30am here now and i can't think straight anymore. Link to comment https://forums.phpfreaks.com/topic/109695-query-string-question/#findComment-562918 Share on other sites More sharing options...
BrianM Posted June 11, 2008 Author Share Posted June 11, 2008 I hear you there, I'm surprised I'm in the mood to learn anything at 2:45 am :| Well I think I'm going to continue this tomorrow, going to hit the hay and call it a night. Thanks for all your help! Link to comment https://forums.phpfreaks.com/topic/109695-query-string-question/#findComment-562925 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.