Jump to content

[SOLVED] Little help with .php?...


05rmerce

Recommended Posts

Hi,

 

Please stay with me as I am finding this quite difficult to explain :)

 

I would like to make a script that gets information from the database and echoes it to the page.  That I can do.  But more importantly I would like to have one file that is able to choose a different piece of information based on the URL.

 

For example, in this post window:

 

http://www.phpfreaks.com/forums/index.php?action=post;board=1.0

 

Index.php can show the index, or with the bit on the end generates the post form.

 

I would like to know how to add/use the

 

?action=post;board=1.0

 

Bit in my own scripts.

 

I hope that has come across well.

 

Thanks in advance :)

05rmerce

 

Link to comment
Share on other sites

Not exactly :)

 

I would like a page to display different things based on what is after the .php?

 

For example:

 

http://server.com/index.php //Would load the main index from the database

http://server.com/index.php?view=002 //Would execute different script to load the information for record 002.

 

I think I can work it out myself, if you could be kind enough to demonstrate how I could set what the user has typed in (The URL) as a variable.

Link to comment
Share on other sites

Read up on the $_GET info. In your second example the PHP variable $_GET['view'] would contain your value of 002 (or possibly just 2).

 

If you want to assign it to another variable, simply do:

 

$view = $_GET['view'];

 

However, it's good coding practice to make sure the index "view" is there first. So, something like this is better:

 

$view = isset($_GET['view']) ? $_GET['view'] : '';

 

 

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.