<?php
define('CURSCRIPT', 'product');
require_once './engine/common.inc.php';
$pagerecords=15;
$curpage=isset($page)?$page:1;
$startrecord=($curpage-1)*$pagerecords;
$totalrecord=$db->result($db->query("SELECT count(*) FROM g_products WHERE top = 0"),0);

/*     if top productions execute  */
$topq = $db->query("SELECT * FROM g_products a LEFT JOIN g_attachments b ON a.productid = b.bid AND b.typeid=2 AND b.islogo=1 where a.top = 1 ORDER BY ord DESC LIMIT $startrecord , $pagerecords");
$key = 0;
	while($topproduct=$db->fetch_array($topq))
		{
			if($topproduct['storename']){
				$topproduct['logo']="./clientdata/attachment/product/".replaceimg($topproduct['storename']);
			}else{
				$topproduct['logo']="./images/common/g_non_image.gif";
			}
			$topproduct['productintro']=nl2br($topproduct['productintro']);
			$topproducts[$key]=$topproduct;
			$key++;
			}

$q = $db->query("SELECT * FROM g_products a LEFT JOIN g_attachments b ON a.productid = b.bid AND b.typeid=2 AND b.islogo=1 where a.top=0 ORDER BY ord DESC LIMIT $startrecord , $pagerecords");
$key = 0;
while($product=$db->fetch_array($q))
{

	if($product['storename']){
		$product['logo']="./clientdata/attachment/product/".replaceimg($product['storename']);
		}else{
		$product['logo']="./images/common/g_non_image.gif";
	}
	$product['productintro']=nl2br($product['productintro']);
	$products[$key]=$product;
	$key++;
}
$multipage=multi($totalrecord, $pagerecords, $curpage, "product.php");
include($templatedir."product.tpl.php");

