[ Поиск ] - [ Пользователи ] - [ Календарь ]
Полная Версия: Сортировка в витрине
ViRuSreloaded

//show active products
$q = db_query("SELECT count(*) FROM ".PRODUCTS_TABLE." WHERE categoryID=$categoryID AND enabled=1 AND Price>=0") or die (db_error());
$g_count = db_fetch_row($q);
$g_count = $g_count[0];

if ($g_count) // there are products in the category
{

if ($offset>$g_count) $offset=0;

$q = db_query("SELECT productID FROM ".PRODUCTS_TABLE." WHERE categoryID=$categoryID AND enabled=1 AND Price>=0 ORDER BY customers_rating") or die (db_error());

$result = array();
$i=0;
while ($row = db_fetch_row($q))
{
if ($i>=$offset && $i<$offset+$products_count)
$result[] = $row[0];
$i++;
}

$min = $products_count;
if ($min > $g_count-$offset) $min = $g_count-$offset;

$out .= "<center>\n";

//top navigator
showNavigator($g_count, $offset, $products_count, "index.php?categoryID=$categoryID&",$out);

//draw $cols_count products in each row
$out .= "<p>

<table
width=100% cellspacing=6>
<tr>
<td
width=100 align=center bgcolor=#008000><b><font color=#FFFFFF><nobr>Логотип</nobr></font></b></td>
<td
width=215 align=center bgcolor=#008000><b><font color=#FFFFFF><nobr>Наименование компании</nobr></font></b></td>
<td
width=180 align=center bgcolor=#008000><b><font color=#FFFFFF><nobr>Корпоративный сайт</nobr></font></b></td>
<td
bgcolor=#008000 align=center><b><font color=#FFFFFF><nobr>Основные сведения</nobr></font></b></td>
</tr>
</table>
";

$out .= "<table border=0 cellpadding=5 width=100%>";

for ($i=0; $i<$min; $i++)
{
if ($i % $cols_count == 0) $out .= "<tr>";

$out .= "<td width=50% valign=top>";
showGood($result[$i], true, $out); //show item
$out .= "</td>";

if (($i+1) % $cols_count == 0) $out .= "</tr>";
}






$out .= "</table>";

//lower navigator
showNavigator($g_count, $offset, $products_count, "index.php?categoryID=$categoryID&",$out);

$out .= "</center>\n";


}
else //there are no items in the category. search for items in it's subcategories
{

//are there any subcateogires?
$i = 0;
while ($i<count($cats) && $cats[$i][2] != $categoryID) $i++;
if ($i == count($cats)) //empty
$out .= "";
else //search for items
{
//create query

$s = "SELECT productID FROM ".PRODUCTS_TABLE." WHERE enabled=1 AND Price>=0 ";
$a = get_Subs($categoryID);
if (count($a) > 0)
{
$s.= " AND (categoryID=$a[0]";
for ($i=1;$i<count($a);$i++)
{
$s.=" OR categoryID=$a[$i]";
}
$s.= ")";
}

$q = db_query(str_replace("SELECT productID","SELECT count(*)",$s)) or die (db_error());
$cnt = db_fetch_row($q); $cnt = $cnt[0];


$q = db_query($s." ORDER BY customers_rating DESC") or die (db_error());
$i=0;

if ($cnt > 0) $out .= "<br>".PRODUCTS_BEST_CHOISE.":";

//$cols_count products in each row
$out .= "<p><table border=0 cellpadding=5 width=100%>";

while ($i<$products_count && $row = db_fetch_row($q)) //show not more than $products_count products
{

if ($i % $cols_count == 0) $out .= "<tr>";

$out .= "<td valign=top width=50%>";
showGood($row[0],true,$out);
$out .= "</td>";

if (($i+1) % $cols_count == 0) $out .= "</tr>";

$i++;
}

$out .= "</table>";

}

}




Вот здесь надо сортировку предусмотреть!

Сейчас стоит по customers_rating

А надо на выбор пользователя либо по customers_rating либо по added_date
Быстрый ответ:

 Графические смайлики |  Показывать подпись
Здесь расположена полная версия этой страницы.
Invision Power Board © 2001-2024 Invision Power Services, Inc.