Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GET method and PHP

I have two questions.

In my webpage (developed by me), I use the GET method to return for example the id of one record that I have in a mySQL database.

For example, one url can be this:

http://www.example.com/example.php?id=1

But in MediaWiki software, they can use this GET method, or one strange method that I don't know, that works like this:

http://www.example.com/example.php/1 

How can I do that my PHP script knows that what the id is 1?

And now I have another question. In MediaWiki software, you can do that the index.php file converts to a virtual wiki directory.

Now the final question is: How can I do that in my webpage, the url for this request to my mySQL database (with a PHP script) is:

http://www.example.com/example/1

Thanks.

P.D: Sorry about my bad English. I'm still learning, because I'm from Spain and in Spain the Enslish is not an official language.

like image 958
Adrià Vilanova Avatar asked Mar 24 '12 16:03

Adrià Vilanova


People also ask

What is difference between GET and POST method in PHP?

In GET method we can not send large amount of data rather limited data is sent because the request parameter is appended into the URL. In POST method large amount of data can be sent because the request parameter is appended into the body.

What is $_ GET and $_ POST in PHP?

$_GET is an array of variables passed to the current script via the URL parameters. $_POST is an array of variables passed to the current script via the HTTP POST method.


1 Answers

You can do that with rewrites (e.g. via .htaccess)

Have a look at this page: http://www.workingwith.me.uk/articles/scripting/mod_rewrite

like image 68
EricSchaefer Avatar answered Sep 19 '22 23:09

EricSchaefer