How can I get $_GET values to a variable

Nisfan

In my page, there are multiple $_GET values. ie

if(isset($_GET["projects"]))
{ .....    }
else if(isset($_GET["research"]))
{ ...... }
else if(isset($_GET["publication"]))
{ ..... }

...upto 10 elseif's

Can I shorten this? Can I get these values {projects,research, publication,..} in a variable.?

Havenard

Ok so I guess I figured out what you want from your comments. Lets see.

$types = array('projects', 'research', 'publication'); // add as many as you want
$valid = array_intersect_key($_GET, array_flip($types));

if (count($valid) > 1)
    die "More than one category is set, this is invalid.";

if (!$valid)
    die "No category was set, you must choose one.";

foreach ($valid as $type => $value) // just to split this one element array key/value into distinct variables
{
    $value = mysql_real_escape_string($value); // assuming you are using mysql_*
    $sql = "SELECT * FROM table WHERE $type = '$value'";
}

...

이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.

침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제

에서 수정
0

몇 마디 만하겠습니다

0리뷰
로그인참여 후 검토

관련 기사

분류에서Dev

how can I get a some values in strings in bash script

분류에서Dev

How can I get full-ranged random float values?

분류에서Dev

How can I set a session variable in a servlet and get it in a JSP?

분류에서Dev

How can I get a RejectedExecutionException

분류에서Dev

How can I get a solution for this?

분류에서Dev

How I can get list item values when I click on list view

분류에서Dev

How can I write a recursive function to get an array representing the set of every permutation of values?

분류에서Dev

How can I get the specific values I selected from SQLite Database? When I click on the button the app jut crashes

분류에서Dev

How can I get an array from an If statement?

분류에서Dev

How can i get the hasClass of click target?

분류에서Dev

How can i get request in Filter

분류에서Dev

How can I get SSRS to create subheadings?

분류에서Dev

How can I get the CurrentSite object in Orchard?

분류에서Dev

How can I get FacetFilter work properly?

분류에서Dev

How can I get the type of a Type?

분류에서Dev

How can I get memory card information?

분류에서Dev

How can I get an accurate length of a BigInteger?

분류에서Dev

How can I get the var of a multimethod?

분류에서Dev

How can I get the source code of a command?

분류에서Dev

Why can't I get the exit values of a command in this bash script?

분류에서Dev

AngularJS - How can I get data from GET method

분류에서Dev

How can I get the name of the file I'm uploading

분류에서Dev

How can I pause a loop until I get a users input?

분류에서Dev

How do I get the right values out of this JSON?

분류에서Dev

How do I get a variable with the name of the user running ansible?

분류에서Dev

add variable values of tables to get a total

분류에서Dev

get values from unicode variable type on python

분류에서Dev

How can I get pygame for Python3?

분류에서Dev

Ubuntu Software Centre is gone! How can I get it back?

Related 관련 기사

  1. 1

    how can I get a some values in strings in bash script

  2. 2

    How can I get full-ranged random float values?

  3. 3

    How can I set a session variable in a servlet and get it in a JSP?

  4. 4

    How can I get a RejectedExecutionException

  5. 5

    How can I get a solution for this?

  6. 6

    How I can get list item values when I click on list view

  7. 7

    How can I write a recursive function to get an array representing the set of every permutation of values?

  8. 8

    How can I get the specific values I selected from SQLite Database? When I click on the button the app jut crashes

  9. 9

    How can I get an array from an If statement?

  10. 10

    How can i get the hasClass of click target?

  11. 11

    How can i get request in Filter

  12. 12

    How can I get SSRS to create subheadings?

  13. 13

    How can I get the CurrentSite object in Orchard?

  14. 14

    How can I get FacetFilter work properly?

  15. 15

    How can I get the type of a Type?

  16. 16

    How can I get memory card information?

  17. 17

    How can I get an accurate length of a BigInteger?

  18. 18

    How can I get the var of a multimethod?

  19. 19

    How can I get the source code of a command?

  20. 20

    Why can't I get the exit values of a command in this bash script?

  21. 21

    AngularJS - How can I get data from GET method

  22. 22

    How can I get the name of the file I'm uploading

  23. 23

    How can I pause a loop until I get a users input?

  24. 24

    How do I get the right values out of this JSON?

  25. 25

    How do I get a variable with the name of the user running ansible?

  26. 26

    add variable values of tables to get a total

  27. 27

    get values from unicode variable type on python

  28. 28

    How can I get pygame for Python3?

  29. 29

    Ubuntu Software Centre is gone! How can I get it back?

뜨겁다태그

보관