you will have to search for the customer to get the ID first. Once you have the id, you insert the cid into the other table along with the other information. (Two separate queries). The wildcard here is that the customer may or may not exist. This means, FIRST you look up to see if the customer exists. If he does, then you use their cid, if you find nothing, go ahead and Insert a new one. Then search for the customer using all the information you just used to insert. Use the resulting cid for the insert into the orders table.
What would make the whole thing a lot easier is to keep track of the client from the very very beginning.
Have the user sign in. Keep track of which one she is using a session variable that has her cid.
You didnt' mention anything about username or password. I would add a password field, and use the email as the username.
Have them sign in before you order. Use her sign-in info to look up the cid. Keep track of it using session_start() session_register("cid"); When she makes an order, you've already got the cid.
If sign-in fails, offer to sign up.