Hi,
As I won´t have thousands of products and only a few categories and brands, I would like to display categories, brands and merchants on the same page. I would like to display them as plain, single columns without the grouping by letter as the a to z is now. The columns should be in alphabetical order.
Is there an easy way to do this?
Best regards,
Daniel.
Thanks David, you read my mind!
This was exactly what I pictured.
Hi David,
I´ve added some extra fields that I would like to display in the same way, but when I for example replaced merchant in your code with one of my extra fields, type, I get this error:
[SELECT * FROM `feeds` ORDER BY type][Unknown column 'type' in 'order clause']
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\xampp\htdocs\pt\includes\database.php on line 26
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in C:\xampp\htdocs\pt\includes\database.php on line 31
I´ve had some trouble with getting the extra fields into the database, but now it seems to work, I can check each individual value in phpMyAdmin, so I have no idea why this isn´t working.
Thankful for any help!
Daniel
Hi Daniel,
Did you mean to select from the products table rather than feeds? In the all.php, only the merchants list uses the feeds table, the others (category and brand) use products...
Cheers,
David.
Hi David!
What is the easisest way to know if the atoz.php script is showing categories and not products or brand? I want to show print only when it is showing categories.
Hi,
If you want to add code to html/atoz.php only when a category index is being displayed, have a go with:
<?php if (strpos($_SERVER["PHP_SELF"],"categories.php")!== FALSE): ?>
<!-- HTML for categories page here -->
<?php endif; ?>
Cheers,
David.
--
PriceTapestry.com
Hi Daniel,
Probably easiest to do this in a self-contained script - have a go with this as a starting point...
all.php
<?php
require("includes/common.php");
$banner["h2"] = "<strong>All A-Z</strong>";
require("html/header.php");
require("html/menu.php");
require("html/searchform.php");
require("html/banner.php");
print "<h3>Merchants</h3>";
print "<ul>";
$sql = "SELECT * FROM `".$config_databaseTablePrefix."feeds` ORDER BY merchant";
if (database_querySelect($sql,$rows))
{
foreach($rows as $feed)
{
if ($config_useRewrite)
{
$href = $config_baseHREF."merchant/".tapestry_hyphenate($feed["merchant"])."/";
}
else
{
$href = $config_baseHREF."search.php?q=merchant:".urlencode($feed["merchant"]).":";
}
print "<li><a href='".$href."'>".$feed["merchant"]."</a></li>";
}
}
print "</ul>";
print "<h3>Categories</h3>";
print "<ul>";
$sql = "SELECT DISTINCT(category) as category FROM `".$config_databaseTablePrefix."products` ORDER BY category";
if (database_querySelect($sql,$rows))
{
foreach($rows as $product)
{
if ($product["category"])
{
if ($config_useRewrite)
{
$href = $config_baseHREF."category/".tapestry_hyphenate($product["category"])."/";
}
else
{
$href = $config_baseHREF."search.php?q=category:".urlencode($product["category"]).":";
}
print "<li><a href='".$href."'>".$product["category"]."</a></li>";
}
}
}
print "</ul>";
print "<h3>Brands</h3>";
print "<ul>";
$sql = "SELECT DISTINCT(brand) as brand FROM `".$config_databaseTablePrefix."products` ORDER BY brand";
if (database_querySelect($sql,$rows))
{
foreach($rows as $product)
{
if ($product["brand"])
{
if ($config_useRewrite)
{
$href = $config_baseHREF."brand/".tapestry_hyphenate($product["brand"])."/";
}
else
{
$href = $config_baseHREF."search.php?q=brand:".urlencode($product["brand"]).":";
}
print "<li><a href='".$href."'>".$product["brand"]."</a></li>";
}
}
}
print "</ul>";
require("html/footer.php");
?>
Cheers,
David.