Hi,
In products.php, my line 12 is:
$sql = "SELECT * FROM `".$config_databaseTablePrefix."products` WHERE name LIKE '%".database_safe($q)."%' ORDER BY price LIMIT ".$config_resultsPerPage;
I use "WHERE name LIKE" because my feeds use unique model numbers - so rather usefully the script then includes differently formatted model numbers from different feeds.
Is there a way to edit the above code to display only one result (ideally the lowest priced) for each merchant?
Thanks
Hi Stephen,
This would be best done after the query. The following line is currently:
$numRows = database_querySelect($sql,$rows);
Try changing this to the following code:
$newRows = array();
$merchants = array();
if (database_querySelect($sql,$rows))
{
foreach($rows as $row)
{
if (!$merchants[$row["merchant"]])
{
$newRows[] = $row;
$merchants[$row["merchant"]] = 1;
}
}
}
$rows = $newRows;
$numRows = count($rows);
Hope this helps!
Cheers,
David.