You are here:  » Merchant logo's from the database

Support Forum



Merchant logo's from the database

Submitted by scorpionwsm on Sat, 2011-11-12 11:30 in

Hi
I have my database setup with extra tables for merchant info etc. from which i would like to use the merchant logos on the prices pages instead of "logos/logo.gif" would this be possible?

I have pt_products etc. for the main site and....

merchant_products for the merchant info... i would like to use image_url from the merchant_products table for the merchant logos

TIA

Submitted by support on Sun, 2011-11-13 09:04

Hi,

Sure, try adding something like this to the top of html/prices.php:

<?php
$ins 
= array();
$logos = array();
foreach(
$prices["products"] as $product)
{
  
$ins[] = database_safe($product["merchant"]);
}
$in implode(",",$ins);
$sql "SELECT merchant,image_url FROM merchant_products WHERE merchant IN (".$in.")";
database_querySelect($sql,$results);
foreach(
$results as $result)
{
  
$logos["merchant"] = $result["image_url"];
}
?>

And then where the logo is displayed look for the following code (line 11 before the above modification)

<td><a href='<?php print $product["merchantHREF"]; ?>'><?php print (file_exists("logos/".$product["merchant"])?"<img src='".$config_baseHREF."logos/".$product["merchant"]."' border='0' />":$product["merchant"]); ?></a></td>

...and REPLACE with:

<td><a href='<?php print $product["merchantHREF"]; ?>'><?php print ($logos[$product["merchant"]])?"<img src='".$logos[$product["merchant"]]."' border='0' />":$product["merchant"]); ?></a></td>

Cheers,
David.
--
PriceTapestry.com

Submitted by scorpionwsm on Sun, 2011-11-13 11:24

Hi David,
Thanks for that but I'm still unable to get the logo's to appear.

I've changed
$sql = "SELECT merchant,image_url FROM merchant_products WHERE merchant IN (".$in.")";

TO

$sql2 = "SELECT merchant,image_url FROM merchant_products WHERE merchant IN (".$in.")";

to avoid Warning: mysql_fetch_array() errors

But then I was getting Parse error: syntax error, unexpected ')' in...

so I removed the ) from

<?php
>:$product["merchant"]); 
?>

that stopped the errors but still no logo appearing

Any Ideas?

Submitted by support on Sun, 2011-11-13 16:58

Hi,

I just realised the merchants names wouldn't have been in 'single quotes'; so assuming the field names are all correct, try replacing this line:

$ins[] = database_safe($product["merchant"]);

..with:

$ins[] = "'".database_safe($product["merchant"])."'";

Cheers,
David.
--
PriceTapestry.com