View Single Post
  #1  
Old 26th April 2016, 01:17
orichec1000 orichec1000 is offline
Member
 
Join Date: Oct 2015
Posts: 2
Default Arrangment of Torrents / Sql Query to sort Torrrents
Hello everyone,
I tried to sort Appz related torrents from database by calling table "category" but when i use sort by category using php it also mix up other torrents such as movies, Please guide me how can I sort torrents of only one category instead of all from table "category"...
Here is my php codes
PHP Code:
$orderby "ORDER BY torrents.category DESC";
$addparam "";
if (
$_GET["incldead"] == 2)
    
$wherea[] = "visible = 'yes'";
$res mysql_query("SELECT COUNT(*) FROM torrents $where") or die(mysql_error());
$row mysql_fetch_array($res,MYSQL_NUM);
$count $row[0];
if (
$count)
{
  
$pager pager($torrentsperpage$count"browse.php?" $addparam);
  
$query "SELECT torrents.id, torrents.category, torrents.name, torrents.times_completed, torrents.size, torrents.added, torrents.type,  torrents.comments,torrents.numfiles,torrents.filename,torrents.owner,IF(torrents.nfo <> '', 1, 0) as nfoav," .
  
"categories.name AS cat_name, categories.image AS cat_pic, users.username FROM torrents LEFT JOIN categories ON category = torrents.id LEFT JOIN users ON torrents.owner = users.id $where $orderby {$pager['limit']}";
  
$res mysql_query($query) or die(mysql_error()); 

Thanks
Reply With Quote