Detail Page of Products from URL id
3 posts by 2 authors in: Forums > CMS Builder
Last Post: December 16, 2009 (RSS)
By ferrisj - December 16, 2009
I have been searching your forums and found many similar posts, but still haven't been able to get this to work. Any help much appreciated:
I have a table of product_categories (fields: name, content, photo)
I have my main products table that has a "list" field that pulls in the category from product_categories table. I want my products_detail.php page to list all products under a category that is specified in the url from the previous category list page. (ie product_details.php?ipphones-2)
require_once "/home/......./admin/lib/viewer_functions.php";
list($product_categoryRecords, $product_categoryMetaData) = getRecords(array(
'tableName' => 'product_category',
'where' => whereRecordNumberInUrl(1),
'limit' => '1',
));
$product_categoryRecord = @$product_categoryRecords[0]; // get first record
// show error message if no matching record is found
if (!$product_categoryRecord) {
header("HTTP/1.0 404 Not Found");
print "Record not found!";
exit;
}
list($productsRecords, $productsMetaData) = getRecords(array(
'tableName' => 'products',
'where' => "category LIKE '%\t" . mysql_escape($product_categoryRecord['num']) . "\t%'",
));
?>
I have a table of product_categories (fields: name, content, photo)
I have my main products table that has a "list" field that pulls in the category from product_categories table. I want my products_detail.php page to list all products under a category that is specified in the url from the previous category list page. (ie product_details.php?ipphones-2)
require_once "/home/......./admin/lib/viewer_functions.php";
list($product_categoryRecords, $product_categoryMetaData) = getRecords(array(
'tableName' => 'product_category',
'where' => whereRecordNumberInUrl(1),
'limit' => '1',
));
$product_categoryRecord = @$product_categoryRecords[0]; // get first record
// show error message if no matching record is found
if (!$product_categoryRecord) {
header("HTTP/1.0 404 Not Found");
print "Record not found!";
exit;
}
list($productsRecords, $productsMetaData) = getRecords(array(
'tableName' => 'products',
'where' => "category LIKE '%\t" . mysql_escape($product_categoryRecord['num']) . "\t%'",
));
?>
Re: [ferrisj] Detail Page of Products from URL id
By Chris - December 16, 2009
Hi ferrisj,
The above code is for multi-value list fields. If your list field is not multi-value (i.e. your products can belong to only one category) you'll want to use this code instead of the above:
Does that help? Please let me know if you have any questions.
'where' => "category LIKE '%\t" . mysql_escape($product_categoryRecord['num']) . "\t%'",
The above code is for multi-value list fields. If your list field is not multi-value (i.e. your products can belong to only one category) you'll want to use this code instead of the above:
'where' => "category = '" . mysql_escape($product_categoryRecord['num']) . "'",
Does that help? Please let me know if you have any questions.
All the best,
Chris
Chris
Re: [chris] Detail Page of Products from URL id
By ferrisj - December 16, 2009
Gosh, i was so so close :) Hey, you rock, i really appreciate the help.