mysql - Conditional Sorting of Data using php codes from sql database -
i'm having problem sort table values different categories of books , i'm having 10 categories of books. categories mentioned in table entitled "categories" (1, 2, 3,...10) , each category contains more 100 books.
i want sort books 1 category such 1 database , ignore other categories. used following php codes sorted results whole of column "categories" means categories sorted 1 one want sort data single category.
$orderby = "order books.category desc"; $addparam = ""; if ($_get["incldead"] == 2) $wherea[] = "visible = 'yes'"; $res = mysql_query("select count(*) books $where") or die(mysql_error()); $row = mysql_fetch_array($res,mysql_num); $count = $row[0]; if ($count) { $pager = pager($booksperpage, $count, "browse.php?" . $addparam); $query = "select books.id, books.category, books.name, books.times_completed, books.size, books.added, books.type, books.comments,books.numfiles,books.filename,books.owner,if(books.nfo <> '', 1, 0) nfoav," . "categories.name cat_name, categories.image cat_pic, users.username books left join categories on category = categories.id left join users on books.owner = users.id $where $orderby {$pager['limit']}"; $res = mysql_query($query) or die(mysql_error());
output of above code similar below:
my desired output:
please guide me how it'll possible amending in above php codes...
Comments
Post a Comment