<?php //This page is used in conjunction with the AJAX on index.php $sort = $_GET['sort']; $limit = $_GET['limit']; //Conditional statements for the sort mode sent through the URL on request. switch ($sort) { case "mp": $sql = "SELECT * FROM `tutorial` ORDER BY `tutorial_hits` DESC LIMIT {$limit}"; $query = mysql_query($sql); $num = mysql_num_rows($query); $tutorial = mysql_fetch_assoc($query); $sortedby = "Most Popular"; case "hr": $sql = "SELECT * FROM `tutorial` ORDER BY `tutorial_rating` DESC LIMIT {$limit}"; $query = mysql_query($sql); $num = mysql_num_rows($query); $tutorial = mysql_fetch_assoc($query); $sortedby = "Highest Rated"; case "mr": $sql = "SELECT * FROM `tutorial` ORDER BY `tutorial_date` DESC LIMIT {$limit}"; $query = mysql_query($sql); $num = mysql_num_rows($query); $tutorial = mysql_fetch_assoc($query); $sortedby = "Most Recent"; } if($num < 1) { echo "A sort by ". $sortedby. " turned up no results."; } else { echo "Tutorials..."; }?>