Limiting records displayed based on an another recordset?
Posted: Tue Jul 11, 2006 6:41 am
Hi,
I am using php with an MySQL database to build a page that displays all the products in a particular a category. This essentially consists of a repeating region which displays one product after the other. I want to include a “add to basket” button next to each product however each product has several different prices which is stored a separate database table (therefore a dropdown, allowing the user to select the desired option is required). I have successfully created this add to basket button on the “product detailed” page when there is only one product and I can limit the record set base on the value pass in the URL. However, I am not sure how to do this when there is more than one product such as on the category page I am creating. For example, the recordssets might look like:
Product Recordset
+------------------------------
| ID | PRODUCT
| 1 | Green Product
| 2 | Blue Product
+------------------------------
Price Recordset
+------------------------------
| ID | PRICE
| 1 | £1.99
| 1 | £2.99
| 2 | £10.99
| 2 | £12.99
+------------------------------
I am not sure how to loop through the prices in the <select> lists so that only the relevant prices are displayed ie When looping through the “Product Recordset” the select list options should be:
ID 1 (Green Product) = £1.99 & £2.99
ID 2 (Blue Product) = £10.99 & £12.99
Is there a way to relate the two recordsets so that only the prices relating a particular product are shown in the drop down?
Hope this makes sense
Thanks
Wayne
I am using php with an MySQL database to build a page that displays all the products in a particular a category. This essentially consists of a repeating region which displays one product after the other. I want to include a “add to basket” button next to each product however each product has several different prices which is stored a separate database table (therefore a dropdown, allowing the user to select the desired option is required). I have successfully created this add to basket button on the “product detailed” page when there is only one product and I can limit the record set base on the value pass in the URL. However, I am not sure how to do this when there is more than one product such as on the category page I am creating. For example, the recordssets might look like:
Product Recordset
+------------------------------
| ID | PRODUCT
| 1 | Green Product
| 2 | Blue Product
+------------------------------
Price Recordset
+------------------------------
| ID | PRICE
| 1 | £1.99
| 1 | £2.99
| 2 | £10.99
| 2 | £12.99
+------------------------------
I am not sure how to loop through the prices in the <select> lists so that only the relevant prices are displayed ie When looping through the “Product Recordset” the select list options should be:
ID 1 (Green Product) = £1.99 & £2.99
ID 2 (Blue Product) = £10.99 & £12.99
Is there a way to relate the two recordsets so that only the prices relating a particular product are shown in the drop down?
Hope this makes sense
Thanks
Wayne