Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

$get multiple variables from url

Tags:

php

get

I am making a photography website. In the DB there is an images table, events table and category table which as linked via foreign keys. At the moment i generate events from when a photo was taken from the database and turn them into anchor links.

<?php
while ( $a_row = mysql_fetch_row( $result ) ){

 foreach ( $a_row as $field ){

?>
<a href="images.php?event=<?php echo $field;?> "> <php? echo $field; ?> </a>
<?php
 }
}
?>

When the link is clicked a script gets the variable from get in the url: /images.php?**event**=eventCalledParty

foreach($_GET as $value)
{
$event = $value;
}
$event = mysql_real_escape_string($event);

My question is - If i was to implement categories and have a url that looks like:

/images.php?event=eventCalledParty&category=categoryCalledFashionPhotography

How would i seperate these two variables from the url to use in my queries.

Thank You.

like image 426
slexAtrukov Avatar asked Dec 10 '22 13:12

slexAtrukov


2 Answers

These will automatically show up in these variables...

$_GET['event']
$_GET['category']

PHP does all of this work for you.

like image 88
Brad Avatar answered Dec 26 '22 05:12

Brad


$event = mysql_real_escape_string($_GET['event']);
$category = mysql_real_escape_string($_GET['category']);
like image 45
Your Common Sense Avatar answered Dec 26 '22 05:12

Your Common Sense