Hello David,
I already implement node 822 & 892.
1. Then i updated my jump.php
New
<?php
require("includes/common.php");
$sql = "SELECT merchant,buy_url FROM `".$config_databaseTablePrefix."products` WHERE id=".database_safe($_GET["id"]);
database_querySelect($sql,$rows);
$product = $rows[0];
$sql = "UPDATE `".$config_databaseTablePrefix."feeds` SET clicks=clicks+1 WHERE merchant = '".$product["merchant"]."'";
database_queryModify($sql,$insertID);
$sql = "UPDATE `".$config_databaseTablePrefix."products` SET clicks=clicks+1 WHERE id='".database_safe($_GET["id"])."'";
database_queryModify($sql,$insertID);
header("Location: ".$product["buy_url"]);
exit();
?>
Old
<?php
require("includes/common.php");
$sql = "SELECT merchant,buy_url FROM `".$config_databaseTablePrefix."products` WHERE id=".database_safe($_GET["id"]);
database_querySelect($sql,$rows);
$product = $rows[0];
$sql = "UPDATE `".$config_databaseTablePrefix."feeds` SET clicks=clicks+1 WHERE merchant = '".$product["merchant"]."'";
database_queryModify($sql,$insertID);
$url = $product["buy_url"];
$url = str_replace("{keyword}",$_GET["keyword"],$url);
header("Location: ".$url);
exit();
?>
Wonder what is the purpose of use for the below scripts in the old jump.php. Pls help.
$url = $product["buy_url"];
$url = str_replace("{keyword}",$_GET["keyword"],$url);
header("Location: ".$url);
2. Most Viewed Stores
Below is the script. It is working fine.
<?php
print "<p>Most Viewed Stores</p>";
$sql = "SELECT merchant FROM `".$config_databaseTablePrefix."feeds` ORDER BY clicks DESC LIMIT 5";
if (database_querySelect($sql,$rows))
{
foreach($rows as $merchant)
{
if ($config_useRewrite)
{
$href = $config_baseHREF."merchant/".tapestry_hyphenate($merchant["merchant"])."/";
}
print "<a href='".$href."'>".$merchant["merchant"]."</a><br>";
}
}
?>
I tried to created for brand and category. See below scripts. But nothing appears. Is this correct.
<?php
print "<p>Most Viewed Brands</p>";
$sql = "SELECT brand FROM `".$config_databaseTablePrefix."feeds` ORDER BY clicks DESC LIMIT 5";
if (database_querySelect($sql,$rows))
{
foreach($rows as $brand)
{
if ($config_useRewrite)
{
$href = $config_baseHREF."brand/".tapestry_hyphenate($brand["brand"])."/";
}
print "<a href='".$href."'>".$brand["brand"]."</a><br>";
}
}
?>
<?php
print "<p>Most Viewed Category</p>";
$sql = "SELECT category FROM `".$config_databaseTablePrefix."feeds` ORDER BY clicks DESC LIMIT 5";
if (database_querySelect($sql,$rows))
{
foreach($rows as $category)
{
if ($config_useRewrite)
{
$href = $config_baseHREF."category/".tapestry_hyphenate($brand["category"])."/";
}
print "<a href='".$href."'>".$brand["category"]."</a><br>";
}
}
?>
thanks
jack
Hello David,
Thank you very much. You are superb.
cheers
jack
Hello David,
1. Most popular products.
I created most popular products. Below is the script. Wonder if it is correct. Looks ok.
<?php
print "<table width='250'>";
print "<p>Most Popular Products</p>";
$sql = "SELECT * FROM `".$config_databaseTablePrefix."products` ORDER BY clicks DESC LIMIT 10";
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 "<tr>";
print "<td style='border-bottom:1px dotted;border-color:#cccccc;'><a href='".$productHREF."' ><img width='80' height='80' border='0' src='".$product["image_url"]."' alt='".$product["name"] ."' /></a> </td>";
print "<td valign='top' style='border-bottom:1px dotted;border-color:#cccccc;'><font size=1><a href='".$productHREF."'> ".$product["name"]."</a><br>";
print "<br>";
print $config_currencyHTML.$product["price"]." <br></font>\n"; print "</td>";
}
}
print "</tr>";
print "</table>";
?>
2. Most view stores.
Apart from display just the text link to merchant. How can i replace it using logo instead from the below scripts
<?php
if ($config_useRewrite)
{
$href = $config_baseHREF."merchant/".tapestry_hyphenate($product["merchant"])."/";
}
else
{
$href = $config_baseHREF."search.php?q=merchant:".urlencode($product["merchant"]);
}
print "<a href='".$href."'>";
if (file_exists("logos/".$product["merchant"]))
{
print "<img border='0' src='".$config_baseHREF."logos/".$product["merchant"]."' />";
}
else
{
print "<img border='0' src='".$config_baseHREF."logos/default.png' />";
}
print "</a>";
?>
This will link back to the merchant page example www.abc.com/merchant/Modern-Car/
Now how can i add selected (with limit) brand and category for this particular merchant to the above code. (something like kelkoo.co.uk - hide this url).
Output looks like
merchant logo brand
1
2
category:
1
2
Then when i am in the merchant page example www.abc.com/merchant/Modern-Car/, i can hv the option
1. to list all brands (A-Z)and categories (A-Z) of this merchant. (with count)
2. to display only top 10 brands and category from this merchant. (with count)
3. to diplay top 10 products from this merchant based on clicks.
4. to display all products review of this merchant. (with count)
Output looks like
Merchant: Modern Car
Total Brand (20)
1. brand a (200) - 200 refer to 200 products from this merchant
2. brand b (100) - 100 refer to 100 products from this merchant
3.
Total Category (10)
1.category a (150) - 150 refer to 150 products from this merchant
2.
3.
Total Review (9)
1. product a (5) - 5 refer to 5 reviews for this product from this merchant
2. product b (3)
3. product c (1)
How possible to do this.
thanks
jack
Hello Jack,
Taking this one step at a time, your code to display the merchant logos looks fine, so let me know if
there is a particular problem with that. There may be performance issues doing this, but as a first
go at listing categories and brands (per merchant); try this for starters:
<?php
if ($config_useRewrite)
{
$href = $config_baseHREF."merchant/".tapestry_hyphenate($product["merchant"])."/";
}
else
{
$href = $config_baseHREF."search.php?q=merchant:".urlencode($product["merchant"]);
}
print "<a href='".$href."'>";
if (file_exists("logos/".$product["merchant"]))
{
print "<img border='0' src='".$config_baseHREF."logos/".$product["merchant"]."' />";
}
else
{
print "<img border='0' src='".$config_baseHREF."logos/default.png' />";
}
print "</a>";
print "<table>";
print "<tr>";
print "<td>" // categories
$sql = "SELECT DISTINCT(category) AS category FROM `".$config_databaseTablePrefix."`products WHERE merchant = '".database_safe($product["merchant"])."' LIMIT 3";
if (database_querySelect($sql,$rows))
{
print "<ul>";
foreach($rows as $row)
{
if ($config_useRewrite)
{
$href = $config_baseHREF."category/".tapestry_hyphenate($row["category"])."/";
}
else
{
$href = $config_baseHREF."search.php?q=category:".urlencode($row["category"]);
}
print "<li><a href='".$href."'>".$row["category"]."</a></li>";
}
print "</ul>";
}
print "</td>";
print "<td>"; // brands
$sql = "SELECT DISTINCT(brand) AS brand FROM `".$config_databaseTablePrefix."`products WHERE merchant = '".database_safe($product["merchant"])."' LIMIT 3";
if (database_querySelect($sql,$rows))
{
print "<ul>";
foreach($rows as $row)
{
if ($config_useRewrite)
{
$href = $config_baseHREF."brand/".tapestry_hyphenate($row["brand"])."/";
}
else
{
$href = $config_baseHREF."search.php?q=brand:".urlencode($row["brand"]);
}
print "<li><a href='".$href."'>".$row["brand"]."</a></li>";
}
print "</ul>";
}
print "</td>";
print "</tr>";
print "</table>";
?>
Cheers,
David.
Hi David,
The below script is from html/topstores.php. Then i add the script you written. But not working.
<?php
print "<p>Most Viewed Stores</p>";
$sql = "SELECT merchant FROM `".$config_databaseTablePrefix."feeds` ORDER BY clicks DESC LIMIT 5";
if (database_querySelect($sql,$rows))
{
foreach($rows as $merchant)
{
if ($config_useRewrite)
{
$href = $config_baseHREF."merchant/".tapestry_hyphenate($merchant["merchant"])."/";
}
print "<a href='".$href."'>".$merchant["merchant"]."</a><br>";
}
}
?>
Hi,
The code above is using the $product variable; on the merchant page; you will need to replace:
$product["merchant"]
with:
$merchant["merchant"]
Cheers,
David.
Hi David,
Here is the entire script. I hv change all from product to merchant. Still can't get thru.
<?php
print "<p>Most Viewed Stores</p>";
$sql = "SELECT merchant FROM `".$config_databaseTablePrefix."feeds` ORDER BY clicks DESC LIMIT 5";
if (database_querySelect($sql,$rows))
{
foreach($rows as $merchant)
{
if ($config_useRewrite)
{
$href = $config_baseHREF."merchant/".tapestry_hyphenate($merchant["merchant"])."/";
}
print "<a href='".$href."'>".$merchant["merchant"]."</a><br>";
}
}
?>
<?php
if ($config_useRewrite)
{
$href = $config_baseHREF."merchant/".tapestry_hyphenate($merchant["merchant"])."/";
}
else
{
$href = $config_baseHREF."search.php?q=merchant:".urlencode($merchant["merchant"]);
}
print "<a href='".$href."'>";
if (file_exists("logos/".$merchant["merchant"]))
{
print "<img border='0' src='".$config_baseHREF."logos/".$merchant["merchant"]."' />";
}
else
{
print "<img border='0' src='".$config_baseHREF."logos/default.png' />";
}
print "</a>";
print "<table>";
print "<tr>";
print "<td>" // categories
$sql = "SELECT DISTINCT(category) AS category FROM `".$config_databaseTablePrefix."`products WHERE merchant = '".database_safe($merchant["merchant"])."' LIMIT 3";
if (database_querySelect($sql,$rows))
{
print "<ul>";
foreach($rows as $row)
{
if ($config_useRewrite)
{
$href = $config_baseHREF."category/".tapestry_hyphenate($row["category"])."/";
}
else
{
$href = $config_baseHREF."search.php?q=category:".urlencode($row["category"]);
}
print "<li><a href='".$href."'>".$row["category"]."</a></li>";
}
print "</ul>";
}
print "</td>";
print "<td>"; // brands
$sql = "SELECT DISTINCT(brand) AS brand FROM `".$config_databaseTablePrefix."`products WHERE merchant = '".database_safe($merchant["merchant"])."' LIMIT 3";
if (database_querySelect($sql,$rows))
{
print "<ul>";
foreach($rows as $row)
{
if ($config_useRewrite)
{
$href = $config_baseHREF."brand/".tapestry_hyphenate($row["brand"])."/";
}
else
{
$href = $config_baseHREF."search.php?q=brand:".urlencode($row["brand"]);
}
print "<li><a href='".$href."'>".$row["brand"]."</a></li>";
}
print "</ul>";
}
print "</td>";
print "</tr>";
print "</table>";
?>
Is there anything else that i forgot to change.
thanks
jack
Hello Jack,
My apologies, there is a typo in each of the SQL statements. Where you have:
`".$config_databaseTablePrefix."`products
...this should be:
`".$config_databaseTablePrefix."products`
(the second ` is in the wrong place)
If you correct that in both the categories and brands SQL it should do the trick...
Cheers,
David.
Hello David,
I changed the above. Still no results. Btw, you mentioned performance issues. Can you explain so i can understand it better.
thanks
jack
Hello Jack,
Could you email the entire file that has this modification and i'll check it out on my test server for you...
Regarding performance, the issue is the number of queries being performed (2 per merchant), and the fact they are potentially slow(ish) queries themselves. Depending on the number of products and your server performance it may or may not be an issue - just something to be aware of!
Cheers,
David.
Hello David,
I hv emailed the files. thanks
cheers
jack
Hello David,
I hv got your email. Everything works perfectly fine. thanks you so much.
Btw, how can i add another link to the merchant product search result page.
print "See all products>>";
thanks
jack
Hello Jack,
Glad that's all working. If you wanted to put this link just below the table with the category and brand links (it's the same linking code as the main merchant name link); look for the following line in the topstores.php that I sent you (right at the end of the foreach() loop):
print "</table>";
..and add the following code AFTER this line:
if ($config_useRewrite)
{
$href = $config_baseHREF."merchant/".tapestry_hyphenate($merchant["merchant"])."/";
}
else
{
$href = $config_baseHREF."search.php?q=merchant:".urlencode($merchant["merchant"]);
}
print "<a href='".$href."'>See all products »</a>";
Cheers,
David.
Hello David,
Perfectly done. thank you very much.
cheers
jack
hi david and jack.
thanks for sharing the most viewed merchant mod. the merchant mod works fine but the other 2 i cant seem to use.
i cant seem to setup the
most viewed category
most viewed brand
correctly.
and if possible i would like add a
most viewed products
thanks in advance.
atman
Hi atman,
Did you add the new "clicks" field to your products table - this is the most important change required in order to do popular products/brands/categories...
The code for this starts here:
http://www.pricetapestry.com/node/892#comment-7042
Cheers,
David.
hello Jack,
The link is put into the $href variable, but the code below that is using $productHREF, so i've changed $href to $productHREF - that should be all it is:
<?php
print "<table width='250'>";
print "<p>Most Popular Products</p>";
$sql = "SELECT * FROM `".$config_databaseTablePrefix."products` ORDER BY clicks DESC LIMIT 10";
if (database_querySelect($sql,$rows))
{
foreach($rows as $product)
{
if ($config_useRewrite)
{
$productHREF = $config_baseHREF."product/".tapestry_hyphenate($product["name"]).".html";
}
else
{
$productHREF = $config_baseHREF."products.php?q=".urlencode($product["name"]);
}
print "<tr>";
print "<td style='border-bottom:1px dotted;border-color:#cccccc;'><a href='".$productHREF."' ><img width='80' height='80' border='0' src='".$product["image_url"]."' alt='".$product["name"] ."' /></a> </td>";
print "<td valign='top' style='border-bottom:1px dotted;border-color:#cccccc;'><font size=1><a href='".$productHREF."'> ".$product["name"]."</a><br>";
print "<br>";
print $config_currencyHTML.$product["price"]." <br></font>\n"; print "</td>";
}
}
print "</tr>";
print "</table>";
?>
Cheers,
David.
Hello Jack,
This code:
$url = $product["buy_url"];
$url = str_replace("{keyword}",$_GET["keyword"],$url);
...is part of the tracking mod where users are sending a keyword value through to the affiliate network for use in reporting etc.
Regarding your most viewed brands and categories code; these scripts need to SELECT from the products table, not the feeds table. For the brands, try using:
$sql = "SELECT DISTINCT(brand) AS brand FROM `".$config_databaseTablePrefix."products` ORDER BY clicks DESC LIMIT 5";
...and for categories:
$sql = "SELECT DISTINCT(category) AS category FROM `".$config_databaseTablePrefix."products` ORDER BY clicks DESC LIMIT 5";
Cheers,
David.