Hi there
Using these forums I now have page of Merchants, with corresponding logos and description. I also have on each product page, voucher code info if the merchant has issued a voucher code for their products.
What I am trying to do now though is have a page with merchant logos, but only if that merchant has issued a voucher code. The voucher info should be listed alongside the logo. I'm trying but failing!
any ideas?
cheers
PH
Thanks for the quick response!
Yeah, not too sure about that second bit you said...
The code to display merchant logos and descriptions is as follows:
print "<div class='merchantList'><a href='".$href."'>";
if (file_exists("logos/".$feed["merchant"]))
{
print "<img src='".$config_baseHREF."logos/".$feed["merchant"]."' border='0' class='merchantLogos' />";
}
else
{
print $feed["merchant"];
}
print "</a>";
if (file_exists("description/".$feed["merchant"].".txt"))
{
print "<p><span class='merchantDescription'>";
require("description/".$feed["merchant"].".txt");
print "</span></p></div>";
}
else
{
print "</div>";
}
The voucher details are displayed on the product details page and the code to display them is as follows:
<?php
if (file_exists("vouchers/".$product["merchant"]))
{
include("vouchers/".$product["merchant"]);
}
else
{
print "Sorry! No voucher or discount code available for this product at this time.";
}
?>
hope that makes sense!
cheers
PH
Hi PH,
If you could create your "merchants with vouchers" index as described in the first part of my reply; and then email it to me and I'll modify it to include the contents of the voucher code file alongside each merchant's name / logo...
Cheers,
David.
Hey there
OK, tried what you sent on to me, but the page contents do not load - it's just blank.
When I browse to www.mywebsite.com/merchants.php, that page loads as normal.
I do have a folder called "vouchers" with at least 1 file name "Merchatnt Name.txr"
Any ideas?
cheers!
PH
OK - got the page to load
amended this line
$dh = opendir("vouchers"))
to this
$dh = opendir("vouchers");
however the actual voucher and logo details does not appear.
P
Hi PH,
Despite not showing the voucher and logo is it correctly restricting the page to merchants that have a .txt entry in the /vouchers/ folder?
Cheers,
David.
Hi David
um...I guess so!
This is the part that tells it where to look etc
$ins = array();
$dh = opendir("vouchers");
while (($filename = readdir($dh)) !== false)
{
$filename = str_replace(".txt","",$filename);
$ins[] = "'".database_safe($filename)."'";
}
closedir($dh);
$in = implode(",",$ins);
$sql = "SELECT * FROM `".$config_databaseTablePrefix."feeds` WHERE merchant IN (".$ins.") ORDER BY merchant";
Hi Paul,
Could you perhaps email me the URL of the script and I'll take a look and check it out for you...
Cheers,
David.
Yep -
David thanks again - u got it all sorted!
cheers!
ph
Hi PH,
It sounds like this could be achieved using PHP's directory handling functions, and use this to read your directory of coupons to construct a list of merchants with coupons, and then use this as an "IN" clause in the SQL.
To have a go at this, start with a copy of merchants.php and call it, say, merchantsVouchers.php.
Within the the new file you'll find the SQL that SELECTs all merchant's on line 6 as follows:
$sql = "SELECT * FROM `".$config_databaseTablePrefix."feeds` ORDER BY merchant";
Now, assuming that based on other threads you have a folder on your site called "vouchers", and that folder contains files that have the exact name of the merchant, then could REPLACE the above line with the following:
$ins = array();
$dh = opendir("vouchers"))
while (($filename = readdir($dh)) !== false)
{
$ins[] = "'".database_safe($filename)."'";
}
closedir($dh);
$in = implode(",",$ins);
$sql = "SELECT * FROM `".$config_databaseTablePrefix."feeds` WHERE merchant IN (".$in.") ORDER BY merchant";
After that, it would just be a case of require()'ing the voucher code file using the same variable name as you have used to derive the merchant logo image URLs - let me know if you're not sure about this section; and if you could post the relevant section of code that is displaying the merchant names / logos in a loop plus details of your voucher directory etc. I'll work out the code for you...
Cheers,
David.