MATLAB Posted August 19, 2010 Share Posted August 19, 2010 I have not created any code for this as I dont know where to start, or what its even called. I am on about trying to create a page dynamically depending on the id which is selected. Parts of the URL will change depending on what id is selected for example: 'http://www.facebook.com/home.php?sk=h. i am wanting to create a video website, where when the thumbnail of a video is clicked, a new page is loaded with that more details of the video and the video itself, and im guessing the url would change to identify the id of the video. I cannot create a page for every video by hand, as i will have many videos and this is not very efficient. I am just after the name of this technique or a pointer to a tutorial for how to achieve this. Thanks, Matlab Link to comment https://forums.phpfreaks.com/topic/211184-help-needed-dynamically-creating-web-pages/ Share on other sites More sharing options...
DavidAM Posted August 19, 2010 Share Posted August 19, 2010 You are talking about the "Query String". Everything after the ? in the url is a query string that provides parameters to your script. You get a "super-global" array called $_GET. In your example: http://www.facebook.com/home.php?sk=h $_GET['sk'] would contain the value 'h'. Multiple values can be provided by separating them with an ampersand ('&') http://www.facebook.com/home.php?sk=h&id=123 In this case $_GET['sk'] is 'h' and $_GET['id'] is 123. Your script can make decisions based on the values in the $_GET array. Link to comment https://forums.phpfreaks.com/topic/211184-help-needed-dynamically-creating-web-pages/#findComment-1101303 Share on other sites More sharing options...
MATLAB Posted August 19, 2010 Author Share Posted August 19, 2010 Thanks! Would it be a simple if statement so if the value of $_GET = "h" then echo this e.t.c? Link to comment https://forums.phpfreaks.com/topic/211184-help-needed-dynamically-creating-web-pages/#findComment-1101309 Share on other sites More sharing options...
radar Posted August 19, 2010 Share Posted August 19, 2010 do it something like this $_sk = isset($_REQUESt['sk']) ? $_REQUEST['sk'] : ''; $_id = isset($_REQUEST['id']) ? $_REQUEST['id'] : ''; switch ($_sk) { default: // the main page of the website break; case vid: // selected video page.. select * from table where id = $_id echo html here... or stop PHP display HTML with php elements added into it, and then restart PHP... break; } Link to comment https://forums.phpfreaks.com/topic/211184-help-needed-dynamically-creating-web-pages/#findComment-1101315 Share on other sites More sharing options...
MATLAB Posted August 19, 2010 Author Share Posted August 19, 2010 thanks a lot. Do you know what this concept is called so i can look at it in more detail please? Link to comment https://forums.phpfreaks.com/topic/211184-help-needed-dynamically-creating-web-pages/#findComment-1101322 Share on other sites More sharing options...
radar Posted August 19, 2010 Share Posted August 19, 2010 http://php.net/manual/en/control-structures.switch.php will get you started with the switch... i think it makes for easier reading down the road... not as many if elseif elseif elseif elseif else statements needed (if any at all). Link to comment https://forums.phpfreaks.com/topic/211184-help-needed-dynamically-creating-web-pages/#findComment-1101361 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.