|
#1
|
|||
|
|||
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 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"); ?> <table class="categ" border="1" cellpadding="0" cellspacing="5" width="950"> <tbody> <tr> <td width="950"><center> <form method="get" action="browse.php"> <a href="viewrequests.php"><img src="pic/reqs.png" border=0></a><b>Meklēt:</b> <input name="search" size="40" value="" type="text"> <select name="cat"> <option value="0">(Visi)</option> <option value="6">Anime/Cartoon</option> <option value="2">Appz</option> <option value="13">Docs</option> <option value="4">Games/PC</option> <option value="17">Games/PS2</option> <option value="22">Games/PS3</option> <option value="23">Games/PSP</option> <option value="24">Games/Wii</option> <option value="25">Games/X360</option> <option value="14">Images</option> <option value="18">Hentai</option> <option value="2">MiSC</option> <option value="12">Mobile</option> <option value="16">Movies/DVD-RO</option> <option value="11">Movies/SVCD</option> <option value="8">Movies/Oldies</option> <option value="3">Movies/XVID</option> <option value="7">Linux/Unix</option> <option value="15">Music/Video</option> <option value="5">Music/Mp3</option> <option value="26">Movies/DVDR</option> <option value="10">Tv/Episodes</option> <option value="21">Tv/Boxsets</option> </select> </select> <input value="Ok!" type="submit"> <b> Apskatīt failus</b> <select name="incldead"> <option value="0">Aktīvos</option> <option value="1">Arī miru |
#2
|
||||
|
||||
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 "<option value='".$cat['id']."'>".$cat['name']."</option>"; Code:
foreach ($cats as $cat) echo "<img src='images/caticons/".$cat['image']."' border='0' alt='".$cat['name']."' />"; |
#3
|
|||
|
|||
thanks m8 it lists them but needs a corection because i use those images to not use checkboxes any way thanks
got it work 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 "<option value='".$cat['id']."'>".$cat['name']."</option>"; } 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"); ?> <table class="categ" border="1" cellpadding="0" cellspacing="5" width="950"> <tbody> <tr> <td width="950"><center> <form method="get" action="browse.php"> <a href="viewrequests.php"><img src="pic/reqs.png" border=0></a><b>Meklēt:</b> <input name="search" size="40" value="" type="text"> <select name="cat"> <option value="0">(Visi)</option> <option value="6">Anime/Cartoon</option> <option value="2">Appz</option> <option value="13">Docs</option> <option value="4">Games/PC</option> <option value="17">Games/PS2</option> <option value="22">Games/PS3</option> <option value="23">Games/PSP</option> <option value="24">Games/Wii</option> <option value="25">Games/X360</option> <option value="14">Images</option> <option value="18">Hentai</option> <option value="2">MiSC</option> <option value="12">Mobile</option> <option value="16">Movies/DVD-RO</option> <option value="11">Movies/SVCD</option> <option value="8">Movies/Oldies</option> <option value="3">Movies/XVID</option> <option value="7">Linux/Unix</option> <option value="15">Music/Video</option> <option value="5">Music/Mp3</option> <option value="26">Movies/DVDR</option> <option value="10">Tv/Episodes</option> <option value="21">Tv/Boxsets</option> </select> </select> <input value="Ok!" type="submit"> <b> Apskatīt failus</b> <select name="incldead"> <option value="0">Aktīvos</option> <option value="1">Arī miru |
Tags |
browse , categories , images |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
how to add a search box in browse.php | irfan | TBDev | 0 | 22nd October 2009 17:25 |
Need new Images | joeroberts | BT.Manager (phpMyBitTorrent) | 4 | 19th June 2009 02:02 |
browse.php | ahly | Community Cafe | 0 | 12th December 2008 17:12 |
Images, Baners.... | x517530 | Template Shares | 5 | 7th November 2008 04:15 |
Browse | Mika | Template Shares | 3 | 7th September 2008 20:05 |