Hi David,
I'm trying to make a featured category on my homepage, like the featured products. I'm trying to select the category but in debug mode i get the following error:
[SELECT * FROM `products` AND category='Dagaanbieding' ORDER BY sequence][You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'AND category='Dagaanbieding' ORDER BY sequence' at line 1]
The category exists
The code is:
{code saved}
Hi David,
I'm getting closer.
I get some results in debudmode but also another error:
[SELECT * , MIN( price ) AS minPrice, MAX( price ) AS maxPrice, COUNT( id ) AS numMerchants, CASE normalised_name WHEN 'Medisana MTP Bovenarm Bloeddrukmeter met Hartritmestoornisdetectie' THEN WHEN 'Philips 42PFL3605 LCD tv' THEN WHEN 'GOLDRING GX-200 HEADPHONES' THEN END AS sequence FROM `products` WHERE normalised_name IN ('','','') AND category='Dagaanbieding' GROUP BY normalised_name ORDER BY sequence][You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHEN 'Philips 42PFL3605 LCD tv' THEN WHEN 'GOLDRING GX-200 HEADPHONES' THEN EN' at line 1]
Regards,
B.
Hi,
It's nearly there, have a go with the following as your SQL:
$sql = "SELECT name,1 AS SEQUENCE FROM `".$config_databaseTablePrefix."products` WHERE category='Dagaanbieding' LIMIT 10";
Simply change the LIMIT value for more or less products from that category. As it stands that would return the same products every time (and efficiently) - if you wanted random products from that category use:
$sql = "SELECT name,1 AS SEQUENCE FROM `".$config_databaseTablePrefix."products` WHERE category='Dagaanbieding' ORDER BY RAND() LIMIT 10";
...but that would only be recommended for niche sites as the random ordering will require a full table scan by the database.
Cheers,
David.
--
PriceTapestry.com