Show Results from Different Tables

Hi all, right I’m sure this is easy enough to do but I can’t seem to get my head around how to do it. Right, I’m creating an ordering system for my work for which the staff will use to order items through mail-order when customers call the call centre.

The operator fills out the customers details and then scrolls down to enter the products they want. I want to save the customers details to one table and their order details to another. Problem is, how do I display the both of these when the operator searches for a customer and wants to view their previous orders with us?

When the operator takes the call, they have to check whether the customer exists or not first.

I could be wrong, but normally a lookup by postal code in the first instance brings back a list of possible matches.

Failing to find the customer from that list would then invoke the operator creating a new account.

I’d have thought that would be the first task.

Finding an existing customer would involve identifying their unique key, which you use to then lookup any previous orders - which seems to be the thrust of your question.

Clearly you skip that step when creating a new customer.

Depending on your situation Ajax would be ideal for this kind of demanding GUI lookup work.

But to start off, create 2 traditional work streams, existing customer and new customer, use multiple pages for each.

Once those work, investigate using Ajax to reduce those pages, and then work out how to share form elements and pop-up and hide divs on the page depending on the use-case, and try and merge those 2 work streams together - hopefully into a single user-friendly page.

Hi Cups, thank you for your message. You make a lot of sense, didn’t take into consideration your concept of doing this system, now reworking a couple of things to achieve this. I guess I would need to display the products and customers details by using a join on the MySQL Query? :smiley:

Essentially yes, in pseudo code:


if( $customer_found ){

$customer_id = get_customer_id($name);

}

"select * from old_orders where customer_id = $customer_id order by date desc" ;

//then display the orders

It depends on the makeup of your tables, but I would not have qualms about doing just two database queries. 1) to get the customer (to see if the exists, in effect) and 2) if so, get all of their orders.