View Single Post
  #1  
Old 27th March 2013, 23:48
mat22 mat22 is offline
Senior Member
 
Join Date: Jun 2009
Latvia
Posts: 119
Default Movies show all years
Hello!
First I wanted to ask in chat but then I decided that this might be easier and faster. So I got this code in one part of my website:
Code:
$current_year = '2013';
$where = $current_year; //Default
if($_GET["year"] == '00'){
$where = '2000';
}
if($_GET["year"] == '01'){
$where = '2001';
}
if($_GET["year"] == '02'){
$where = '2002';
}
if($_GET["year"] == '03'){
$where = '2003';
}
if($_GET["year"] == '04'){
$where = '2004';
}
if($_GET["year"] == '05'){
$where = '2005';
}
if($_GET["year"] == '06'){
$where = '2006';
}
if($_GET["year"] == '07'){
$where = '2007';
}
if($_GET["year"] == '08'){
$where = '2008';
}
if($_GET["year"] == '09'){
$where = '2009';
}
if($_GET["year"] == '10'){
$where = '2010';
}
if($_GET["year"] == '11'){
$where = '2011';
}
if($_GET["year"] == '12'){
$where = '2012';
}
if($_GET["year"] == '13'){
$where = '2013';
}
And then I have this:
Code:
<select name=\"year\">
<option value=\"00\">2000</option>
<option value=\"01\">2001</option>
<option value=\"02\">2002</option>
<option value=\"03\">2003</option>
<option value=\"04\">2004</option>
<option value=\"05\">2005</option>
<option value=\"06\">2006</option>
<option value=\"07\">2007</option>
<option value=\"08\">2008</option>
<option value=\"09\">2009</option>
<option value=\"10\">2010</option>
<option value=\"11\">2011</option>
<option value=\"12\">2012</option>
<option value=\"13\">2013</option>
</select>&nbsp;&nbsp;<input class=\"btn\" type=\"submit\" value=\"Submit\" />
All is good but only thing is - how to modify this code so I can have an option "All years" so it shows stuff from all years not just one? By the way it's for part of website that's called "Movies" where there are all best movies from year 2000 until now.

Edit
Forgot to mention that it would be nice to see them sorted by year (2013 first, then 2012, 2011 etc.) when showing all. I added query below:
Code:
$res = mysql_query("SELECT premieres.id, premieres.name, premieres.year, premieres.genre, premieres.descr, premieres.imdb, premieres.imdb_rating, premieres.uploaded, premieres.url, premieres.poster, premieres.owner, premieres.ori_name, users.username, users.class FROM premieres LEFT JOIN users ON premieres.owner = users.id WHERE year = '$where' ORDER BY id DESC $limit");
Now it sorts them by ID. When I take away this year thing and edit it to
Code:
ORDER BY year
it shows only movies from 2013th and some from 2012th but not all because I have about 3 pages of them filled when sorting by ID but when by year - only 1 page showing.

Last edited by mat22; 28th March 2013 at 00:12.
Reply With Quote