I have problem with my php sorting...
I use _SESSION because I want to store sorting for another page, I think it's right.
This is my code:
<?php
$sql = "SELECT * FROM movies";
$_SESSION['sort'] = isset($_GET['sort']);
if (isset ($_SESSION['sort']) == 'Year')
{
$sql .= " ORDER BY year";
}
elseif (isset($_SESSION['sort']) == 'IMDB')
{
$sql .= " ORDER BY IMDBrating";
}
elseif (isset($_SESSION['sort']) == 'user')
{
$sql .= " ORDER BY userrating";
}
?>
<select name="sort" id="sort" tabindex="1">
<option value="Year">Year</option>
<option value="IMDB">IMDB rating</option>
<option value="user">user rating</option>
</select>
<?php
$pagesize = 5;
$recordstart = (int)(isset($_GET['recordstart'])) ? $_GET['recordstart'] : 0;
$sql01 = "SELECT * FROM movies LIMIT $recordstart, $pagesize";
$records=mysql_query($sql01);
$result = mysql_query("SELECT count(id) FROM movies");
$totalrows = mysql_fetch_row($result);
while ($movies=mysql_fetch_array($records)){
echo '<div class="movie_box"><p><div class="news_img"><div class="cover"><img src="'.$movies['cover'].'" width = "183px" height = "271px"/></div><br><button class="trailer_button" type="button">Trailer</button></div><strong><p class="h3"><div class="content">'.$movies['name'].'</p></strong>'.$movies['plot'].'<br><br><strong>Žanr</strong>:'.$movies['genre'].'<br><strong>IMDB ocjena</strong>:'.$movies['IMDBrating'].'<br><strong>Director</strong>:'.$movies['director'].'<br><strong>Glumci</strong>:'.$movies['Starring'].'<br><strong>Ocjena korisnika</strong>:</div><br><div class="trailer">'.$movies['trailer'].'</div><div class="dark"></div></p></div>';
}
if ($recordstart > 0){
$prev = $recordstart - $pagesize;
$url = $_SERVER['PHP_SELF'].'?recordstart='.$prev;
printf('<a id="prev" href="%s"><</a>',$url);
}
if ($totalrows > ($recordstart + $pagesize)){
$next = $recordstart + $pagesize;
$url = $_SERVER['PHP_SELF'].'?recordstart='.$next;
printf('<a id="next" href="%s">></a>',$url);
}
?>
There is no error but still no sorting. Now I edit post and you can see another part with another page script.
$sqland post it back here. Also, that code doesn't show any queries being made.$sqlstring, but no queries are being made. Is that the entire code?isset()is confusing and awkward. And I suspect it will always result in the firstifblock always beingtrue.