Jump to content

Filter MySQL Results and Insert Multiple Rows with the Same Value


HP_Design

Recommended Posts

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.  :)

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.