close ad
Install the LAtest Updates to Work with CC 2017 and CC 2018
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

repeat products inside a repeat categories

Thread began 10/30/2012 6:21 pm by Christopher West | Last modified 10/31/2012 1:18 pm by Christopher West | 427 views | 2 replies |

Christopher WestCommunity Expert

repeat products inside a repeat categories

Hi. I must be tired as I am sure I done this before but for the life of me I cannot get it this process to work...

(this is not an ecommerce website with URLs, just a simple page showing typs of products).

In the database I have two tables:
Products:
ProductsID
ProductsName
ProductsLink (this stores a value from the categories table)

Categories
CategoriesID
CategoriesName
CategoriesPhoto

I have set up a page where there are 6 product categories and they all display on screen using a regular repeat region.

Now under each of those categoies I wanted to display all products relating to that categories.

I have tried many different recordsets using different JOIN methods etc and just cannot get it to work.

Just wanted to know what im missing :(

Here are some code snippets

"SELECT * FROM categories INNER JOIN products ON products.ProductsLink = categories.CategoriesID"

.........................................................................

<?php
$row_count=1;
?>
<?php do { ?>
<div class="product"<?php echo(($row_count%3==0)?' style="margin-right=0;"':' style="margin-right:22px"'); ?>>
<div class="prod-hdr">
<p><?php echo $row_rsProducts['CategoriesName']; ?></p>
</div>
<div class="prod-img"><img src="photos/<?php echo $row_rsProducts['CategoriesPhoto']; ?>" alt="cookshop and kitchenware products" width="278" height="186"></div>
<div class="prod-itm">
<ul>
<li><?php echo $row_rsProducts['ProductsName']; ?></li>
</ul>
</div>
</div>
<?php
$row_count++;
?>
<?php } while ($row_rsProducts = mysql_fetch_assoc($rsProducts)); ?>

Sign in to reply to this post

Ray BorduinWebAssist

What I usually do in this case is instead of doing any JOINs at all, just create two recordsets with just single table references and have one filter off the other inside the repeated region.

So the steps might be:

1) Create your category recordset
2) Create your products recordset filtered with a url parameter ($_GET["CategoryID"] for intstance)
3) Create your category repeat region (done);
4) Create your products repeat region (note: DW won't let you nest, so you can create it below and copy and paste to move the product repeated region into the category repeated region.
5) Copy and paste the products recordset code into the category repeated region as well.
6) Add this code above the products recordset inside the category repeated region:
<?php $_GET["CategoryID"] = $row_rsCategories["CategoryID"]; ?>


That should do it and will allow more flexibility than you might have trying to do it with a single repeat region and joins.

Sign in to reply to this post

Christopher WestCommunity Expert

Thanks Ray that worked like a charm :) I was on the right track with one of my initial attempts in terms of referencing a URL variable (but since no URL variables were being passed I couldnt work it out...however I didnt think to assign a local variable to a URL variable so thats how its done :)


regards

Chris

Sign in to reply to this post

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...