Page 1 of 1

client vs server

Posted: Fri Nov 12, 2010 2:07 am
by blackmagik
Hi,

Would be great to get some thoughts on a project I am currently working on. I am new to PHP.

I have clients that need to connect to MYSQL database to select products out of a table.

It has to be secured. I use PHP to login and check with every page loaded.

My question comes when client select products. As I see it there are a couple of options.
1. Load MYSQL table data when page loads, fill dropdownlists and then uses client side scripting to select and add to a list before posting order to server.
2. Dynamically load table using PHP and write selection to table.

What is best practice? When is it better to use client side opposed to server side scripting? To add to the mix I have to fill a second dropdownlist based on first selection. Also has to fill a HTML table while client is adding products, allowing client to edit selection before finally posting to MYSQL database. Basically a very simple shopping cart.

Thank you in advance

Re: client vs server

Posted: Fri Nov 12, 2010 2:56 pm
by skaterdav85
Well in my opinion, and I am sure most would agree, that it would be better to have a JS-driven interface where users can select items and load them into a cart without doing a page refresh. This would improve usability and meet user expectations. When a user clicks 'Go', your PHP script will do some processing of some sort and take you to the next page in the shopping cart flow.
To add to the mix I have to fill a second dropdownlist based on first selection.
To do this, you'll need to use AJAX. Basically you'll call a function on your first select menu that populates the 2nd form object with the proper value(s). Look into AJAX via jQuery.