Note that there are some explanatory texts on larger screens.

plurals
  1. POComparing two mysql db tables/arrays in php and updating based on timestamp
    primarykey
    data
    text
    <p>Horrible title I know, I couldn't find a better way to articulate my problem.</p> <p>I searched through SO without success, but if the answer's already out there, feel free to link it and I will read it thoroughly.</p> <hr> <p>I'm building a book ordering system. People will order books throughout the month, and one large order arrives at the end of every month.</p> <p>Orders get recorded into an Order table with the following fields: </p> <pre><code>order_id, book_id, quantity, language, person_ordering, timestamp, month, year </code></pre> <p>When orders arrive, they are inputted into an Received table with the following fields:</p> <pre><code>book_id, quantity, language </code></pre> <p>Now suppose one person orders (2) copies of book 1. And another person orders (3). And another (5). For a grand total of (10). Then the order arrives and it only has 7 copies.</p> <p>I'm trying to write a script/function that will find out:</p> <ul> <li>Which persons will receive their copies of the book (it's first come first serve, so the people that ordered it first will have their order fulfilled first.</li> <li>If a person can only have their order partially fulfilled, to update the Order table (or possible a new Pending Orders table is needed?) to reflect that they have X amount still waiting to be fulfilled. Then the following month, their orders would be fulfilled first, again, based on date ordered.</li> </ul> <p>I thought about pulling the information from the Orders table based on time-stamp of when the order was made and sorting through it, then pulling the information out of the Received table and somehow comparing the two arrays and updating a third array? Or perhaps there's a simpler solution that I'm missing. </p> <p>If more information is needed, I will gladly provide. I've been pulling my hair out over this problem for 2 days straight. Any help would be appreciated.</p> <p>Thanks!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload