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
https://forums.phpfreaks.com/topic/85989-solved-little-help-with-php/
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.

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'] : '';

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.