/    Sign up×
Community /Pin to ProfileBookmark

Drop down boxes with php help

Hey, i have a gallery of pictures and i want to sort them by two different drop down boxes. I have a ‘Date’ drop down box that includes years like 2006,2005 and i have a ‘Genre’ drop down box that includes Genre’s like Comedy, Romance etc.

I know how to sort the pictures by one drop down box but i dont know how to add to it. What i mean is that if i sort it by the year 1999 the address would be …. ‘mywebsite.php?year=1999’ but now i have sorted it by the year 1999 i would now like to sort it with Genre ‘Comedy’

So how can i add the genre ‘Comedy’ on to the address line… ‘mywebsite.php?year=1999’ by means of a drop down box?

Many thanks
Matt

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@littlenedAug 17.2006 — Hey, i have a gallery of pictures and i want to sort them by two different drop down boxes. I have a 'Date' drop down box that includes years like 2006,2005 and i have a 'Genre' drop down box that includes Genre's like Comedy, Romance etc.

I know how to sort the pictures by one drop down box but i dont know how to add to it. What i mean is that if i sort it by the year 1999 the address would be .... 'mywebsite.php?year=1999' but now i have sorted it by the year 1999 i would now like to sort it with Genre 'Comedy'

So how can i add the genre 'Comedy' on to the address line... 'mywebsite.php?year=1999' by means of a drop down box?

Many thanks

Matt[/QUOTE]


Basically if you create a form with 2 drop down lists on it, one called year and the other called genre, this will send an url similar to mysite.php?year=1999&genre=comedy

where are you getting the data from? if its from mysql you can use if statements to generate the sql statement depending of the selection by the user.

$year = $_POST['year'];

$genre = $_
POST['genre'];

if ($year <> '' AND $genre == '') { $sql = "Select * from Table ORDER BY $year"; }

if ($year == '' AND $genre <> '') { $sql = "Select * from Table ORDER BY .$genre"; }

if ($year <> '' AND $genre <> '') { $sql = "Select * from Table ORDER BY $year,$genre"; }

I might have some of the code wrong there but it should give you an idea.
Copy linkTweet thisAlerts:
@matty_y2002authorAug 17.2006 — i am getting the data from a mysql table called uploads
×

Success!

Help @matty_y2002 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.5,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...