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

Do I need to create a seperate table for each product in MySQL?

Thread began 8/14/2013 3:33 pm by Jean | Last modified 8/16/2013 2:48 pm by Jason Byrnes | 235 views | 5 replies |

Jean

Do I need to create a seperate table for each product in MySQL?

I have 4 products on 4 different rows in one table (the free products table you supplied). But when I finish the "add to cart button" procedures on all 4 of my product pages (4 different add to cart buttons, 1 per product page) & test it out, The add to cart button always puts the first product from the first row from the "products table" in the cart on all of my product pages. Even though I have 4 different record sets made 1 for each page. Is there some way to tell the PHP the "product ID #" for each product so it knows what row to grab the info from? Is there something I need to do in the server behaviors? Sorry if this seems like a silly question...I am fairly new to MySQL & PHP.

Sign in to reply to this post

Jason ByrnesWebAssist

send a copy of your pages please so i can get a better idea of how you have set them up.

from your description, it sounds lie it should work, so I'll need to examine the code.

Sign in to reply to this post

Jean

RE: Do I need to create a seperate table for each product in MySQL?

Jason,
Please see attached files.
— Jean

Sign in to reply to this post

Jason ByrnesWebAssist

The way you are creating the catalog pages is an inefficient use of a a database.

When suing a database, you don't need to create a separate page for each product, instead, you would create a results page that lists all products, and a details page to show the details of a specific product.

The Results page would have a link to the details page, and would pass the Product ID as a URL variable to tell the details page what product to show, for example:
product_details.php?ID=23

the recordset on the details page would be set up to filter the table based on the ID URL Variable:

for example
SELECT * FROM products WHERE productID = paramID

Variable:
Name: paramID
Type: Integer
Default Value: -1
Runtime Value: $_GET['ID']


The where clause on the recordset would return only the requested product.

In the way you have the pages created, you are creating a separate page for each product, but the recordset on each page does not have a where clause to tell the database which product it should return. This is causing the add to cart button to return the first product each time. if you do it this way, you need to explicitly tell the recordset which product record to return.

Edit the recordset on each page, in the filtering section, select the ID column and set the filter to 'Equals' 'Entered Value' and enter the ID number for the product to return.


For more details on creating a dynamic product catalog, we have some tutorial you may find helpful:

Getting Started With MySQL And Dynamic WebSites
Create a product catalog

Sign in to reply to this post

Jean

RE: Do I need to create a seperate table for each product in MySQL?

Jason, Thanks for the quick and very helpful response. I am new to php and MySQL...The client wanted a stand alone cart and not a service provider for eCom. Your eCart 5 got rave reviews across the net...especially with PayPal and Dreamweaver users. This is definitely new ground that I am covering and needed some assistance. Thanks again & have a great day!

— Jean :-)

Sign in to reply to this post

Jason ByrnesWebAssist

You're welcome.

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