include_once('conn.php');
include_once('includes.php');
if(empty($_GET[page]))
{
$page=1;
}
else
{
$page=$_GET[page];
}
$ByPage = '10';
//--> start record for db query limit
$Start = ($page-1)*$ByPage;
$query = array();
if(!empty($_GET['special']))
{
$q_spcl=escape_string($_GET['special']);
switch($q_spcl) {
case 'vhb':
$query[] = " (shipping_group=1) AND (group_units >0)";
$result_title='
VHB (Virtual Herb Bag) Items
';
$seo_page_title=$site_url.'/categories.php?special=vhb';
$spcl_html=<<
Low shipping cost with our Virtual Herb Bags. Add upto 8 units
of selected products to your order at one low shipping price of just $3.50.
EOD;
break;
default:
} // end switch, special category query
}
if(!empty($_GET[what]))
{
$q_what=escape_string($_GET[what]);
$query[] = " (ItemName like '%$q_what%' or ItemDesc like '%$_GET[what]%') ";
}
if(!empty($_GET[CategoryID]))
{
$q_cat_id=intval($_GET[CategoryID]);
//-->@mod Jul 26, 2016
//-->@extra category multi-select
$query[] = " ((ItemCategory = '$q_cat_id') OR ( FIND_IN_SET($q_cat_id,prod_extra_category) >0 )) ";
}
if(!empty($_GET[SubcategoryID]))
{
$q_subcat=intval($_GET[SubcategoryID]);
$query[] = " ItemSubcategory = '$q_subcat' ";
}
if(!empty($query))
{
$my_query = implode(" and ", $query);
$my_query = " where $my_query";
}
if(!empty($_GET[ord1]))
{
$q_ord=escape_string($_GET[ord1]);
$order_by = " order by $q_ord ";
}
else if($q_spcl == 'vhb') {
$order_by = " ORDER BY ItemName ASC ";
}
else
{
$order_by = " order by ItemID DESC";
}
//show the catalog content
//$q1 = "select isFree, ItemID, ItemName, ItemCategory,ItemPrice,ItemImageURL,ItemDesc from dd_catalog $my_query $order_by limit $Start, $ByPage";
//--> get full data from catalog
$q1 = "select * from dd_catalog $my_query $order_by limit $Start, $ByPage";
$r1 = mysql_query($q1) or die(mysql_error());
if(mysql_num_rows($r1) > '0')
{
$product_cat=$_GET[CategoryID];
$q2="select CategoryName from dd_categories where CategoryID='$product_cat'";
$r2=mysql_query($q2);
if(($r2) && mysql_num_rows($r2))
{
$a2=mysql_fetch_array($r2);
$result_title=''.$a2[CategoryName].'
';
$seo_page_title=seo_format_title($a2);
} // end if
$col = $tcs_resultRow1;
while($a1 = mysql_fetch_array($r1))
{
$x_item_id=intval($a1['ItemID']);
if($col == $tcs_resultRow1)
{
$col = $tcs_resultRow2;
}
else
{
$col = $tcs_resultRow1;
}
/*
//--> item price
$price=($a1[isFree]) ? '0.00':$a1[ItemPrice];
if($price)
{
$price_tag='
Price: '.$aset[currency_sign].$price.'
';
}
else
{
$price_tag='
Price: '.$aset[currency_sign].'0.00 Free
';
} // end if, price
*/
//--> get price structure table
$price_tag=get_price_struct_table($a1,false,true);
//--> item description
$desc=$a1[ItemDesc];
if($desc)
{
$desc=getExcerpt($desc,0,500);
$desc_tag='Description:
'.$desc.'
';
} // end if, desc
//--> item image
$img_url=$a1[ItemImageURL];
if($img_url)
{
//--> get fixed width image
$img_tag=fixedWidthImage($img_url,100,1,'',$a1[ItemName]);
}
else
{
$img_tag=fixedWidthImage($site_url.'/images/no_image.gif',100,1,'',$a1[ItemName]);
} // end if, item image
//--> no image border
$img_tag=str_replace('
add to cart link
if($a1[isFree])
{
//--> Free
$free_dl_link=seo_free_dl_url($a1[ItemID]);
$add_cart_link='
';
}
else
{
//--> Paid
$prod_inv_instock=intval($a1['product_in_stock']);
$prod_inv_qty=intval($a1['product_inv_qty']);
if( ($prod_inv_instock <=0) || ($prod_inv_qty <=0) ) {
//-->@don't show add to cart button
$add_cart_link='';
} else {
//$add_cart_link='
';
$add_cart_link='
';
} // end if, show add to cart button
} // end if
$prod_link=seo_product_url($a1[ItemID]);
$result_rows .= "\n\t | \n\t | \n\t\n
\n\n";
break;
case 1: // subscription
//--> add subscribe link
$x_prod_id=$a1[ItemID];
$x_form_type='sub'; // subscription form
$prod_link=seo_product_url($a1[ItemID]);
$subscribe_url=get_subscribe_url($x_prod_id,$x_form_type);
$subscribe_link='
';
$result_rows .= "\n\t | \n\t | \n\t\n
\n\n";
break;
case 2: // installment plan
break;
default:
} // end switch
} // end while
$qnav = "select count(*) from dd_catalog $my_query";
$rnav = mysql_query($qnav) or die(mysql_error());
$anav = mysql_fetch_array($rnav);
$rows = $anav[0];
//--> how many pages total for db query
$pages = ceil($rows/$ByPage);
if($q_spcl == 'vhb') {
//-->@VHB pagination
$spcl_base_url=$site_url.'/categories.php?special=vhb';
//--> previous page
if($page > 1)
{
$PrevPage=intval($page-1);
$seoPrevPage=$spcl_base_url.'&page='.$PrevPage;
$PrevPageLink=" << Previous\n ";
} // end if
//--> next page
if($page < $pages)
{
$NextPage=intval($page+1);
$seoNextPage=$spcl_base_url.'&page='.$NextPage;
$NextPageLink=" Next > >\n ";
} // end if
if($rows > $ByPage)
{
$NextPrev = '
';
$NextPrev .= '| '.$PrevPageLink.' | ';
$NextPrev .= "";
$NextPrev .= "| ";
for($i = 0; $i < $pages; $i++)
{
$i2 = $i + 1;
if($i2 == $page)
{
$links[] = " $i2\n";
}
elseif($PageStart < $rows)
{
$seoPageLinks=$spcl_base_url.'&page='.$i2;
$links[] = " $i2\n\t ";
}
}
$links2 = implode(" | ", $links);
$NextPrev .= $links2;
$NextPrev .= " | ";
$NextPrev .= "
\n";
$NextPrev .= ' | '.$NextPageLink.' |
';
}
}
else {
//--> previous page
if($page > 1)
{
$PrevPage=intval($page-1);
$seoPrevPage=seo_category_url($_GET[CategoryID],$PrevPage);
$PrevPageLink=" << Previous\n ";
} // end if
//--> next page
if($page < $pages)
{
$NextPage=intval($page+1);
$seoNextPage=seo_category_url($_GET[CategoryID],$NextPage);
$NextPageLink=" Next > >\n ";
} // end if
if($rows > $ByPage)
{
$NextPrev = '
';
$NextPrev .= '| '.$PrevPageLink.' | ';
$NextPrev .= "";
$NextPrev .= "| ";
for($i = 0; $i < $pages; $i++)
{
$i2 = $i + 1;
if($i2 == $page)
{
$links[] = " $i2\n";
}
elseif($PageStart < $rows)
{
$seoPageLinks=seo_category_url($_GET[CategoryID],$i2);
$links[] = " $i2\n\t ";
}
}
$links2 = implode(" | ", $links);
$NextPrev .= $links2;
$NextPrev .= " | ";
$NextPrev .= "
\n";
$NextPrev .= ' | '.$NextPageLink.' |
';
}
} // end if, special category pagination
//----
include_once("templates/HeaderTemplate.php");
include_once("templates/ResultsTemplate.php");
}
else
{
$product_cat=$_GET[CategoryID];
$q2="select CategoryName from dd_categories where CategoryID='$product_cat'";
$r2=mysql_query($q2);
if(($r2) && mysql_num_rows($r2))
{
$a2=mysql_fetch_array($r2);
$result_title=''.$a2[CategoryName].'
';
$seo_page_title=seo_format_title($a2);
} // end if
include_once("templates/HeaderTemplate.php");
include_once("templates/NoResultsTemplate.php");
}
include_once("templates/FooterTemplate.php");
?>