-2

I have a PHP file that fetches all the data from my local database and when I type the full path on the link localhost/webdev/drinksupphp/retrieve-data.php/

I get this result in the browser :

[
   {
      "ID":1,
      "NOM":"John",
      "PRENOM":"Doe",
      "EMAIL":"johndoe@gmail.com",
      "PASSWORD":"123456"
   },
   {
      "ID":2,
      "NOM":"Jean",
      "PRENOM":"D'Arc",
      "EMAIL":"jean@gmail.com",
      "PASSWORD":"123456"
   },
   {
      "ID":3,
      "NOM":"Teko",
      "PRENOM":"Lou",
      "EMAIL":"lou@gmail.com",
      "PASSWORD":"123456"
   }
]

and my question is, how can I get filter this data (for example by ID=1) through the URL only? Something like : localhost/webdev/drinksupphp/retrieve-data.php?ID=1

Thank you in advance

M. Eriksson
  • 13,450
  • 4
  • 29
  • 40
  • A "URL" doesn't *do* anything, it can't filter anything by itself. – deceze Feb 13 '19 at 11:51
  • The part after `?` in a URL is the query string. [Here's the manual](http://php.net/manual/en/reserved.variables.get.php) about how to get those params. When you've done that, you need to code the logic. So you can pass values through the URL but without you fetching that value and do something with it, it's just there doing nothing. – M. Eriksson Feb 13 '19 at 11:52

1 Answers1

0

No.

You would need the PHP to read the value from the URL and perform the filtering based on it.

Quentin
  • 914,110
  • 126
  • 1,211
  • 1,335