1

So I have the url:

php?id=1

and I currently use

$id = $_GET['id'];

$tPerson_SQLselect = "SELECT FROM jobList WHERE id = '$id'"

And this works fine.

However I am unsure what do when I have the url:

php?id=1,2 

and I want to get and then filter for id= 1 and 2

Many thanks

2 Answers2

1

Can try using explode() & implode(). Also use IN in query string. Example:

$ids = "'" . implode("','", array_filter(explode(',', $_GET['id']))) . "'";
$tPerson_SQLselect = "SELECT * FROM jobList WHERE id IN(".$ids.")";
MH2K9
  • 11,951
  • 7
  • 32
  • 49
0

If you have something like php?id=1&id=2, you can use id[] as key. Check here

Community
  • 1
  • 1
Bestasttung
  • 2,388
  • 4
  • 22
  • 34