N
N
netz-sanya2014-04-08 17:35:37
PHP
netz-sanya, 2014-04-08 17:35:37

How to get variable from url?

There is a url site.ru/fox
Tell me how to display all the data from the database in php where id = fox?
More specifically, how to get the value of (fox)?

Answer the question

In order to leave comments, you need to log in

5 answer(s)
1
1001001 111, 2014-04-08
@IgorO2

$_GET['id'] not?

V
Vladimir, 2014-04-08
@azrail_dev

select * from 'table name' where id='fox' PHP
documentation will help you further

A
Andrew Dabich, 2014-04-08
@dabich

In the root of the site in the .htaccess file you write this

RewriteEngine on
RewriteRule ^/([^/]+)/?$	index.php?id=$1  [L,QSA]

then in index.php you get $_GET['id'] where you pass it to the database request.
"SELECT * FROM users WHERE id=".$_GET['id']

A
Alexey, 2014-04-08
@rdifb0

var_dump($_SERVER['REQUEST_URI']);

V
Vladimir Golovanov, 2014-04-08
@Colwin

People, are you serious? Did everyone forget about SQL injections?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question