Jump to content

Help needed dynamically creating web pages


MATLAB

Recommended Posts

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
Share on other sites

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
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.