Below is my code, and I receive a MySQL error on the query below
$result = mysql_query("select * from plant_info where $category = '$spec' ORDER BY '$resort' LIMIT $offset, $limit") or die (mysql_error());
The error states that
"You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near '= '' LIMIT 10, 10' at line 1"
I am trying to pagination, but that query has nothing wrong with it. Does anyone have another way of writing that query or making pagination?
//=============================
include ("db.php");
$sql = "SELECT FROM plant_info";
$query = mysql_query($sql);
$total_results = mysql_num_rows($query);
$limit = 10; //limit of archived results per page.
$total_pages = ceil($total_results / $limit); //total number of pages
if (empty($page))
{
$page = "1"; //default page if none is selected
}
$offset = ($page - 1) $limit;
$category = $REQUEST['category'];
$spec = $REQUEST['spec'];
$sort_by = $_REQUEST['head'];
if (isset($REQUEST['resort'])){
$resort = $REQUEST['resort'];
$result = mysql_query("select * from plant_info where $category = '$spec' ORDER BY '$resort' LIMIT $offset, $limit") or die (mysql_error());