Hello everyone, my script manages categories and links under them, some categories are vurtual, meaning that they do not have content under them but redirect users to already exicting category with that name. this is accoplished in a way that script look for a field in table (ds_categories) called "goto" if goto is has value then category is virtual so it send the user to a page that refreshed and sends to real category. now i dont want this, i want the user to go streight to category instead of going someplace then being redirected to real page as is the case of other physical categories. this is too long but i'd need to explain you what is the issue. this is code, modify if possible please. thank you very much in advance
Class Process{
Function FormatCatSel($catstr = "Main"){
global $cattable,$conn,$categoryname,$catselid,$catmascatid,$catname,$root_url;
$query = "SELECT name, cat_id, mas_cat_id, goto FROM $cattable WHERE cat_id = $catstr";
$result = db_query($query,$conn);
$rowsel = db_fetch_array($result,"");
$goto = $rowsel["goto"];
if ($goto != ""){
print("");
print("<HEAD>");
print("<META HTTP-EQUIV=\"REFRESH\" CONTENT=\"0; URL=$goto\">");
print("</HEAD>");
print("<BODY>");
print("</BODY>");
print("");
exit;
}
$catname = $rowsel["name"];
$categoryname = $catname;
$catselid = $rowsel["cat_id"];
$catmascatid = $rowsel["mas_cat_id"];
$catsel = " > $catname";
WHILE ($catmascatid > 0):
$query = "SELECT name, cat_id, mas_cat_id FROM $cattable WHERE cat_id = $catmascatid";
$result = db_query($query,$conn);
$rowsel = db_fetch_array($result,$nr);
$catname = $rowsel["name"];
$categid = $rowsel["cat_id"];
$catmascatid = $rowsel["mas_cat_id"];
$openlink = " > <A HREF=\"/c";
$s ="s0.html\">";
$catsel = $openlink . $categid . $s . "$catname</A>" . $catsel;
ENDWHILE;
$catsel = "<A HREF=\"/index.html\">Main</A>" . $catsel;
return $catsel;
}
################################################
Get and format categories in columns for
main pages
Expects: Category ID Number
Returns: Category list as HTML
################################################
Function GetCats($catstr = 0){
################################################
Set up globals to keep from passing a ton of
variables
################################################
global $cattable,$linkcattable, $searchtable,$conn,$numlinks,$rookie,$vet,$tempurl,$numcols;
################################################
Format select statement ordering alphabetically
Bring back number of records.
################################################
$catquery="SELECT * FROM $cattable WHERE mas_cat_id = '$catstr' ORDER BY name";
$catresult = db_query($catquery,$conn);
$catnumber = db_num_rows($catresult);
$catnumber = $catnumber;
################################################
If number of records = 0 then we don't need to
do anything, else we need to format the HTML
################################################
IF ($catnumber > 0) :
$cats = "<TR>";
$flag = 1;
################################################
Once we know we have at least 1 record, we loop
through the recordset until we are finished
retrieving data
################################################
WHILE ($row=db_fetch_array($catresult,"")):
$cat_id = $row["cat_id"];
$goto = $row["goto"];
################################################
Format the select statement to find out how
many links the category has under it.
################################################
$que = "SELECT $linkcattable.lid FROM $linkcattable,$searchtable where $linkcattable.category = '$cat_id' AND $searchtable.priority > -1 AND $searchtable.lid = $linkcattable.lid";
$queresult = db_query($que,$conn);
$numlinks = db_num_rows($queresult);
$numlinks = "$numlinks";
if ($goto != ""){
$numlinks = "Go There";
}
$dbrow = db_fetch_array($queresult,"");
$lid = $dbrow["lid"];
################################################
Format select statement to find out whether
the category contains new or veteran links
and put together the rookie and vet tags
################################################
$newque = "SELECT date FROM $searchtable, $linkcattable WHERE ($searchtable.lid = $linkcattable.lid AND $linkcattable.category = '$cat_id' AND date > '" . date("Y-m-d H:i:s", (time()-$timenew-$timenew2-$timenew3)) . "' AND $searchtable.priority > -1)";
$newresult = db_query($newque,$conn);
if (db_num_rows($newresult) > 0)
{
$rookie="<small><sup class=\"rookie3\">New</sup></small>";
}
else
{
$rookie="";
}
$newque = "SELECT date FROM $searchtable, $linkcattable WHERE ($searchtable.lid = $linkcattable.lid AND $linkcattable.category = '$cat_id' AND date > '" . date("Y-m-d H:i:s", (time()-$timenew-$timenew2)) . "' AND $searchtable.priority > -1)";
$newresult = db_query($newque,$conn);
if (db_num_rows($newresult) > 0)
{
$rookie="<small><sup class=\"rookie2\">Newer</sup></small>";
}
$newque = "SELECT date FROM $searchtable, $linkcattable WHERE ($searchtable.lid = $linkcattable.lid AND $linkcattable.category = '$cat_id' AND date > '" . date("Y-m-d H:i:s", (time()-$timenew)) . "' AND $searchtable.priority > -1)";
$newresult = db_query($newque,$conn);
if (db_num_rows($newresult) > 0)
{
$rookie="<small><sup class=\"rookie\">Newest</sup></small>";
}
################################################
If we are displaying the subcategories as links
then we need to format these now.
otherwise, we display the description
################################################
if ($subcatlink == 1){
$tempdesc = "";
$linkquery = "SELECT name, cat_id from $cattable where mas_cat_id = $cat_id";
$linkresult = db_query($linkquery,$conn);
WHILE ($linkrow = db_fetch_array($linkresult,"")){
$linkcat_id = $linkrow["cat_id"];
$linkcategory = $linkrow["name"];
$tempdesc .= "<A HREF='$root_url/index.php3?catstr=$linkcat_id'>$linkcategory, </A>";
}
$description = $tempdesc;
}
else{
$description = $row["description"];
}
$category = $row["name"];
$templine="";
include ("catlink.php3");
$cats= $cats . $catlinks;
################################################
if we have reached the right number of columns,
end the row and start a new row
################################################
if ($flag == $numcols){
$cats = $cats . "</TR><TR> ";
$flag=1;
}
else{
$flag = $flag + 1;
}
$catlinks = "";
ENDWHILE;
$cats = $cats . "</TR>";
ENDIF;
################################################
Return the HTML formatted categories.
################################################
return $cats;
}
}