HP_Design Posted June 8, 2009 Share Posted June 8, 2009 I am programming a booking system that will allow a user to enter 1 Item # and then choose several customer #'s to book that item for. Should I do the following or is there a better way? 1. Start the page with a list of all customers (Currently 11,725 Customers) 2. Then filter by Route, Store Type, State, etc. 3. Then store Customer #'s that are left in an array. 4. Loop through each Customer # in the array and add the same 1 Item # to each of the different Customer #'s Insert Item # and Customer # into the table. (Each row would contain Booked Date, Customer Number, Item Number and Item Description) - "The Customer # would be the only value that changed" For example I need to be able to book an Item to each of our customers in Florida. I might have 500 customers that are going to get Item 43543. I do not want to have to put in individual customer numbers. The Item Number will always be the same for each booking. Thank you for your Help and Ideas. Quote Link to comment Share on other sites More sharing options...
alco19357 Posted June 8, 2009 Share Posted June 8, 2009 INSERT INTO table (field1, field2, field 3) VALUES ('value1', 'value2', 'value3'), ('value1', 'value2', 'value3'); // and so on Quote Link to comment Share on other sites More sharing options...
HP_Design Posted June 8, 2009 Author Share Posted June 8, 2009 I know how to make an insert statement but thank you for your help. I am wondering if the best way to accomplish my task is filter my customer #'s put them in an array and loop through the array with the insert statement. Quote Link to comment Share on other sites More sharing options...
alco19357 Posted June 8, 2009 Share Posted June 8, 2009 my point. if you're inserting into the same table columns for each person, then the above post i had would be best. but even still, you'd have to loop an array. i don't see any other way because you'd still have to create the insert string Quote Link to comment Share on other sites More sharing options...
jpratt Posted June 8, 2009 Share Posted June 8, 2009 It appears that you may not have broken your tables down enough. might help to have an items table, a customer table, and a booking table between the two. This would make it so you didn't have to repeat the item details on every entry. Also if an item description changed you would only have to change the one entry to update the item. You can do what you are try in two ways, store everything in an array and loop through that way, or run the query and insert the data in your booking table as the query loops through your results. EDIT Either way you are looping thru an array. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.