Bravo List

Bravo List (http://www.bvlist.com/index.php)
-   TBDev (http://www.bvlist.com/forumdisplay.php?f=20)
-   -   categories images in browse (http://www.bvlist.com/showthread.php?t=2957)

wMan 6th July 2009 13:41

categories images in browse
 
my browse.php
as u can see by now to list categories images in browse i need to set every image by writing it in there but what i want is to make them set themselfs from mysql like categories.php when it lists them
one more thing ... for some reason it sets categorie image from css so basicli there is no need for categories.php if i still need to set every image in 2 files but i can't find a way to fix it or even where is that part who sets image from css :sos: woud be great if someone coud help out a bit [PHP] ob_start("ob_gzhandler");
require_once("include/bittorrent.php");
dbconn(false);
loggedinorreturn();
parked();
maxsysop ();
$cats = genrelist();
$searchstr = unesc($_GET["search"]);
$cleansearchstr = searchfield($searchstr);
if (empty($cleansearchstr))
unset($cleansearchstr);
if ($_GET['sort'] && $_GET['type']) {
$column = '';
$ascdesc = '';
switch($_GET['sort']) {
case '1': $column = "name"; break;
case '2': $column = "numfiles"; break;
case '3': $column = "comments"; break;
case '4': $column = "added"; break;
case '5': $column = "size"; break;
case '6': $column = "times_completed"; break;
case '7': $column = "seeders"; break;
case '8': $column = "leechers"; break;
case '9': $column = "owner"; break;
default: $column = "id"; break;
}
switch($_GET['type']) {
case 'asc': $ascdesc = "ASC"; $linkascdesc = "asc"; break;
case 'desc': $ascdesc = "DESC"; $linkascdesc = "desc"; break;
default: $ascdesc = "DESC"; $linkascdesc = "desc"; break;
}
$orderby = "ORDER BY torrents." . $column . " " . $ascdesc;
$pagerlink = "sort=" . intval($_GET['sort']) . "&type=" . $linkascdesc . "&";
} else {
$orderby = "ORDER BY torrents.id DESC";
$pagerlink = "";
}
$addparam = "";
$wherea = array();
$wherecatina = array();
if ($_GET["incldead"] == 1)
{
$addparam .= "incldead=1&";
if (!isset($CURUSER) || get_user_class() < UC_ADMINISTRATOR)
$wherea[] = "banned != 'yes'";
}
elseif ($_GET["incldead"] == 2)
{
$addparam .= "incldead=2&";
$wherea[] = "visible = 'no'";
}
else
$wherea[] = "visible = 'yes'";
$category = (int)$_GET["cat"];
$all = $_GET["all"];
if (!$all)
if (!$_GET && $CURUSER["notifs"])
{
$all = True;
foreach ($cats as $cat)
{
$all &= $cat[id];
if (strpos($CURUSER["notifs"], "[cat" . $cat[id] . "]") !== False)
{
$wherecatina[] = $cat[id];
$addparam .= "c$cat[id]=1&";
}
}
}
elseif ($category)
{
if (!is_valid_id($category))
stderr("Error", "Invalid category ID $category");
$wherecatina[] = $category;
$addparam .= "cat=$category&";
}
else
{
$all = True;
foreach ($cats as $cat)
{
$all &= $_GET["c$cat[id]"];
if ($_GET["c$cat[id]"])
{
$wherecatina[] = $cat[id];
$addparam .= "c$cat[id]=1&";
}
}
}

if ($all)
{
$wherecatina = array();
$addparam = "";
}
if (count($wherecatina) > 1)
$wherecatin = implode(",",$wherecatina);
elseif (count($wherecatina) == 1)
$wherea[] = "category = $wherecatina[0]";
$wherebase = $wherea;
if (isset($cleansearchstr))
{
$wherea[] = "MATCH (search_text, ori_descr) AGAINST (" . sqlesc($searchstr) . ")";
//$wherea[] = "0";
$addparam .= "search=" . urlencode($searchstr) . "&";
//$orderby = "";
}
$where = implode(" AND ", $wherea);
if ($wherecatin)
$where .= ($where ? " AND " : "") . "category IN(" . $wherecatin . ")";
if ($where != "")
$where = "WHERE $where";
$res = mysql_query("SELECT COUNT(*) FROM torrents $where") or die(mysql_error());
$row = mysql_fetch_array($res);
$count = $row[0];
if (!$count && isset($cleansearchstr)) {
$wherea = $wherebase;
//$orderby = "ORDER BY id DESC";
$searcha = explode(" ", $cleansearchstr);
$sc = 0;
foreach ($searcha as $searchss) {
if (strlen($searchss) <= 1)
continue;
$sc++;
if ($sc > 5)
break;
$ssa = array();
foreach (array("search_text", "ori_descr") as $sss)
$ssa[] = "$sss LIKE '%" . sqlwildcardesc($searchss) . "%'";
$wherea[] = "(" . implode(" OR ", $ssa) . ")";
}
if ($sc) {
$where = implode(" AND ", $wherea);
if ($where != "")
$where = "WHERE $where";
$res = mysql_query("SELECT COUNT(*) FROM torrents $where");
$row = mysql_fetch_array($res);
$count = $row[0];
}
}
$torrentsperpage = $CURUSER["torrentsperpage"];
if (!$torrentsperpage)
$torrentsperpage = 15;
if ($addparam != "") {
if ($pagerlink != "") {
if ($addparam{strlen($addparam)-1} != ";") { // & = &
$addparam = $addparam . "&" . $pagerlink;
} else {
$addparam = $addparam . $pagerlink;
}
}
} else {
$addparam = $pagerlink;
}

if ($count)
{
list($pagertop, $pagerbottom, $limit) = pager($torrentsperpage, $count, "browse.php?" . $addparam);
$query = "SELECT torrents.id, torrents.nuked, torrents.category, torrents.leechers, torrents.seeders, torrents.request, torrents.scene, torrents.free, torrents.name, torrents.times_completed, torrents.size, torrents.added, torrents.comments,torrents.numfiles,torrents.filen ame,torrents.description,torrents.owner,IF(torrent s.nfo <> '', 1, 0) as nfoav," .
// "IF(torrents.numratings < $minvotes, NULL, ROUND(torrents.ratingsum / torrents.numratings, 1)) AS rating, categories.name AS cat_name, categories.image AS cat_pic, users.username FROM torrents LEFT JOIN categories ON category = categories.id LEFT JOIN users ON torrents.owner = users.id $where $orderby $limit";
"categories.name AS cat_name, categories.image AS cat_pic, users.username FROM torrents LEFT JOIN categories ON category = categories.id LEFT JOIN users ON torrents.owner = users.id $where $orderby $limit";
$res = mysql_query($query) or die(mysql_error());
}
else
unset($res);
if (isset($cleansearchstr))
stdhead("Search results for \"$searchstr\"");
else
stdhead("Failu saraksts");
?>





Meklēt:




     Apskatīt failus

djlee 6th July 2009 19:23

There should already be a column in the cats mysql table for storing the cat image, so first of all make sure those are all setup properly. What id do is set these to stuff like dvdr.gif, xvid,gif, music.gif .. then store all the caticons in a folder called "caticons" in the pic or images directory.

then in bittorrent.php inside the genrelist() function add "image" to the category select fields in the mysql query so it will fetch those images u should have set in the table.

then its simply a case of looping through on the browse page, so for your select list you may wanna use

Code:

foreach ($cats as $cat)
 echo "";

and for a list of images
Code:

foreach ($cats as $cat)
 echo "".$cat[";


wMan 7th July 2009 09:00

:friend:thanks m8 it lists them but needs a corection because i use those images to not use checkboxes any way thanks
got it work :fire:
here is my new browse.php
[php] ob_start("ob_gzhandler");
require_once("include/bittorrent.php");
dbconn(false);
loggedinorreturn();
parked();
maxsysop ();

$cats = genrelist();
$searchstr = unesc($_GET["search"]);
$cleansearchstr = searchfield($searchstr);
if (empty($cleansearchstr))
unset($cleansearchstr);
if ($_GET['sort'] && $_GET['type']) {
$column = '';
$ascdesc = '';
switch($_GET['sort']) {
case '1': $column = "name"; break;
case '2': $column = "numfiles"; break;
case '3': $column = "comments"; break;
case '4': $column = "added"; break;
case '5': $column = "size"; break;
case '6': $column = "times_completed"; break;
case '7': $column = "seeders"; break;
case '8': $column = "leechers"; break;
case '9': $column = "owner"; break;
default: $column = "id"; break;
}
switch($_GET['type']) {
case 'asc': $ascdesc = "ASC"; $linkascdesc = "asc"; break;
case 'desc': $ascdesc = "DESC"; $linkascdesc = "desc"; break;
default: $ascdesc = "DESC"; $linkascdesc = "desc"; break;
}
$orderby = "ORDER BY torrents." . $column . " " . $ascdesc;
$pagerlink = "sort=" . intval($_GET['sort']) . "&type=" . $linkascdesc . "&";
} else {
$orderby = "ORDER BY torrents.id DESC";
$pagerlink = "";
}
$addparam = "";
$wherea = array();
$wherecatina = array();
if ($_GET["incldead"] == 1)
{
$addparam .= "incldead=1&";
if (!isset($CURUSER) || get_user_class() < UC_ADMINISTRATOR)
$wherea[] = "banned != 'yes'";
}
elseif ($_GET["incldead"] == 2)
{
$addparam .= "incldead=2&";
$wherea[] = "visible = 'no'";
}
else
$wherea[] = "visible = 'yes'";
$category = (int)$_GET["cat"];
$all = $_GET["all"];
if (!$all)
if (!$_GET && $CURUSER["notifs"])
{
$all = True;
foreach ($cats as $cat)
echo "";
}

if ($all)
{
$wherecatina = array();
$addparam = "";
}
if (count($wherecatina) > 1)
$wherecatin = implode(",",$wherecatina);
elseif (count($wherecatina) == 1)
$wherea[] = "category = $wherecatina[0]";
$wherebase = $wherea;
if (isset($cleansearchstr))
{
$wherea[] = "MATCH (search_text, ori_descr) AGAINST (" . sqlesc($searchstr) . ")";
//$wherea[] = "0";
$addparam .= "search=" . urlencode($searchstr) . "&";
//$orderby = "";
}
$where = implode(" AND ", $wherea);
if ($wherecatin)
$where .= ($where ? " AND " : "") . "category IN(" . $wherecatin . ")";
if ($where != "")
$where = "WHERE $where";
$res = mysql_query("SELECT COUNT(*) FROM torrents $where") or die(mysql_error());
$row = mysql_fetch_array($res);
$count = $row[0];
if (!$count && isset($cleansearchstr)) {
$wherea = $wherebase;
//$orderby = "ORDER BY id DESC";
$searcha = explode(" ", $cleansearchstr);
$sc = 0;
foreach ($searcha as $searchss) {
if (strlen($searchss) <= 1)
continue;
$sc++;
if ($sc > 5)
break;
$ssa = array();
foreach (array("search_text", "ori_descr") as $sss)
$ssa[] = "$sss LIKE '%" . sqlwildcardesc($searchss) . "%'";
$wherea[] = "(" . implode(" OR ", $ssa) . ")";
}
if ($sc) {
$where = implode(" AND ", $wherea);
if ($where != "")
$where = "WHERE $where";
$res = mysql_query("SELECT COUNT(*) FROM torrents $where");
$row = mysql_fetch_array($res);
$count = $row[0];
}
}
$torrentsperpage = $CURUSER["torrentsperpage"];
if (!$torrentsperpage)
$torrentsperpage = 15;
if ($addparam != "") {
if ($pagerlink != "") {
if ($addparam{strlen($addparam)-1} != ";") { // & = &
$addparam = $addparam . "&" . $pagerlink;
} else {
$addparam = $addparam . $pagerlink;
}
}
} else {
$addparam = $pagerlink;
}

if ($count)
{
list($pagertop, $pagerbottom, $limit) = pager($torrentsperpage, $count, "browse.php?" . $addparam);
$query = "SELECT torrents.id, torrents.nuked, torrents.category, torrents.leechers, torrents.seeders, torrents.request, torrents.scene, torrents.free, torrents.name, torrents.times_completed, torrents.size, torrents.added, torrents.comments,torrents.numfiles,torrents.filen ame,torrents.description,torrents.owner,IF(torrent s.nfo <> '', 1, 0) as nfoav," .
// "IF(torrents.numratings < $minvotes, NULL, ROUND(torrents.ratingsum / torrents.numratings, 1)) AS rating, categories.name AS cat_name, categories.image AS cat_pic, users.username FROM torrents LEFT JOIN categories ON category = categories.id LEFT JOIN users ON torrents.owner = users.id $where $orderby $limit";
"categories.name AS cat_name, categories.image AS cat_pic, users.username FROM torrents LEFT JOIN categories ON category = categories.id LEFT JOIN users ON torrents.owner = users.id $where $orderby $limit";
$res = mysql_query($query) or die(mysql_error());
}
else
unset($res);
if (isset($cleansearchstr))
stdhead("Search results for \"$searchstr\"");
else
stdhead("Failu saraksts");
?>





Meklēt:




     Apskatīt failus


All times are GMT +2. The time now is 08:12.

Powered by vBulletin® Version 3.8.11 Beta 3
Copyright ©2000 - 2024, vBulletin Solutions Inc.