close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Display Products within a category

Thread began 1/30/2015 3:09 am by Kumel | Last modified 2/06/2015 1:32 pm by Kumel | 3378 views | 16 replies |

Kumel

Display Products within a category

i have a dynamic category page. page is attached.

i used .htaccess to change url link.

i want to display products in dynamic category page.

ei. if CategoryID=1 from productcategories then display products within the open category..

product-details.php & category-details.php are dynamic page.
From products page when i click on category name page link appears to be as : .../categories/category-name (this is exactly how i wanted)

Now currently on category-detail page i used following codes in RS:

SELECT *
FROM products
WHERE ProductCategoryID = colnamez



& colnamez as : $row_categories['CategoryID']

But this doesn't work. no products are displaying.

Regards

Sign in to reply to this post

Jason ByrnesWebAssist

so the URL is passing the category name:

/categories/category-name

but in the recordset you are trying to use the Category ID:
WHERE ProductCategoryID = colnamez

and then you say:
& colnamez as : $row_categories['CategoryID']

meaning you are using the category ID returned by the recordset.

This is circular logic.

first off, what is the name of the URL variable that is created by your mid rewrite link. in other words, what is mod rewrite converting the URL to:
/categories/category-name

category-name should get converted to a URL variable, something like:
?CategoryName=<Name of category>

in your recordset, you would need to set the WHERE clause to filter the category name column on the URL variable.

Sign in to reply to this post

Kumel

In my productcategory table i have id, name, catlink.

reason i have catlink is for using it for customising category link.

so uses catlink.

Now from categories RS, can i get id of it & link it to products table for displaying filtered products with productcatid.

Regards


my .htaccess page:
RewriteEngine on

RewriteRule ^products/(.*)$ product-details.php?ProductLink=$1 [NC,L,QSA,T=application/x-httpd-php]
RewriteRule ^categories/(.*)$ category-details.php?catlink=$1 [NC,L,QSA,T=application/x-httpd-php]

Sign in to reply to this post

Jason ByrnesWebAssist

so your path will use the catlike value, and your recordset will filter the catlike column on the catlike URL variable.

Sign in to reply to this post

Kumel

attached is my current category page. (dynamic)

unable to fetch product under same category.

category-details uses 'CategoryLink' from productcategories table.
this needs to be linked with 'ProductCategoryID' from products table with CategoryID from productcategories table.



SELECT products.*, productcategories.*
FROM products INNER JOIN productcategories ON products.ProductCategoryID = productcategories.CategoryID
WHERE products.ProductCategoryID = colname1



colnam1 value: $row_categories['CategoryID']


I know this is stupid but i m not able to fix this.

I don't know how do we filter this type of situation.

Sign in to reply to this post

Jason ByrnesWebAssist

your rewrite rule converts the passed category link to URL v variable named catlink:
RewriteRule ^categories/(.*)$ category-details.php?catlink=$1 [NC,L,QSA,T=application/x-httpd-php]


use the UIRL variable in your recordset:
$_GET['catlink']

also, it would seam to me that the link passed the catlike column from your table right? so you should be using the catlink column in the recordset.

Sign in to reply to this post

Kumel

yet not working.
productcategories table is attached.

& its CategoryLink*

Sign in to reply to this post

Kumel

Originally Said By: Jason Byrnes
  your rewrite rule converts the passed category link to URL v variable named catlink:
RewriteRule ^categories/(.*)$ category-details.php?catlink=$1 [NC,L,QSA,T=application/x-httpd-php]


use the UIRL variable in your recordset:
$_GET['catlink']

also, it would seam to me that the link passed the catlike column from your table right? so you should be using the catlink column in the recordset.  




suppose if i m at category page called: xyz

link would be .../categories/x-y-z ('x-y-z' is Categorylink)

now if i use, $_GET['Categorylink'] then its going to use x-y-z as CategoryID.
I want x-y-z's CategoryID to be used to match with product.ProductCategoryID

Sign in to reply to this post

Jason ByrnesWebAssist

in the recordset, filter using the Categorylink column and the catlink URL variable.

if you are trying to get the related products, your recordset should use a join query.

see the following page:
http://www.w3schools.com/sql/sql_join.asp



Note, you say:
now if i use, $_GET['Categorylink']

the url variable that is created by your rewrite rule is name "catlink" not "Categorylink"

RewriteRule ^categories/(.*)$ category-details.php?catlink=$1 [NC,L,QSA,T=application/x-httpd-php]

Sign in to reply to this post

Kumel

sorry but then i changed so that its clear.

catlink is now CategoryLink.

in the recordset, filter using the Categorylink column and the catlink URL variable.


Now i m bit confused here.
I earlier got this sql_join as you mentioned above & used it to display category name by filter ie.:

SELECT products.ProductID, productcategories.CategoryName, products.ProductCategoryID
FROM products INNER JOIN productcategories ON products.ProductCategoryID = productcategories.CategoryID
WHERE products.ProductID = colname1



colname1 value : $row_WADAproducts['ProductID']

Now if i use same logic on display products it doesn't seem to work.

I got this :

SELECT products.*, productcategories.*
FROM products INNER JOIN productcategories ON products.ProductCategoryID = productcategories.CategoryID
WHERE products.ProductCategoryID = colname1



Colname1 : $row_categories['CategoryID']

Sign in to reply to this post
loading

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...