I have a table that I want to narrow down based on $_GET.
example of first url. index.php?year=2011
With that it will show everything in my database based on the date that has 2011 in it. I have a query working fine for that.
but. I want to narrow the search down so that you can click on a month and it will only show the data based on the year and the month
example index.php?year=2011&month=01
How can I put that into a if or else statement? Or should it be a if statement?
My data for date has the information is as example 2011-01-28
If I have one or the other query on/off either statement will work just not on the same page
My year query
SELECT * FROM $table where date like '$year%'
works fine by itself
My year and month query
SELECT * FROM $table where date like '$year-$month-%'
Works fine by itself.
at the top of my page I do have
$year = $_GET['year'];
$month = $_GET['year'];
Can't figure out how to get them to work together. I would like to keep everything on the same page.
TIA