David,
On my index page i would like display latest 10 products for each category :
Catégorie 1 Title:
Product 1 (with image,title,description and MinPrice)
Product2
......
Product10
Catégorie 2 Title:
Product 1
Product2
......
Product10
Catégorie 3 Title:
Product 1
Product2
......
Product10
at this time i display all my products with this query :
<strong>$sql = "SELECT description,image_url,name,MIN(price) as price FROM ".$config_databaseTablePrefix."products GROUP BY name ORDER BY name";</strong>
if (database_querySelect($sql,$rows))
{
foreach($rows as $product)
{
if ($config_useRewrite)
{
$href = $config_baseHREF."product/".tapestry_hyphenate($product["name"]).".html";
}
else
{
$href = $config_baseHREF."products.php?q=".urlencode($product["name"]);
}
print...<em>after all the code to display product</em>
i only need the sql querie after i think i can manage alone....
Thanks
Hi cocota,
Something very similar is described in this thread, so the first thing to would be to implement the changes to includes/admin.php described in the first part of that reply, giving you a `timestamp` field on the database.
With that in place, a modified version of your $sql = ... line giving you the latest 10 products for "Catégorie 1" would be as follows:
$sql = "SELECT description,image_url,name,MIN(price) as price FROM ".$config_databaseTablePrefix."products WHERE category='Catégorie 1' GROUP BY name ORDER BY timestamp DESC";
Cheers,
David.
--
PriceTapestry.com