client vs server

Not for 'how-to' coding questions but PHP theory instead, this forum is here for those of us who wish to learn about design aspects of programming with PHP.

Moderator: General Moderators

Post Reply
blackmagik
Forum Newbie
Posts: 1
Joined: Fri Nov 12, 2010 1:57 am

client vs server

Post 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
skaterdav85
Forum Newbie
Posts: 1
Joined: Thu Nov 11, 2010 5:01 pm

Re: client vs server

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