title: How to compare values in a for loop
body: <p>I want to know if there's a way to compare two values in a for loop. The first represents the current value and the other represents the previous value of the same thing. The reason is that I'm trying to make a storage FIFO system in a program and the way I'm doing it is that I have 2 tables.</p>
  
  <ul>
  <li>The first one is a regular sqlite table that records ins and outs as they happen and exactly the way they're inputted. For example: If the store recieved 2 monitors today for the price of 5000 each then the table will show exactly that. In:2 Price:5000 Total: 10000</li>
  <li>The second one is a table behind the scenes that doesn't appear to
  the user so that we can get the earliest price to make the FIFO
  system work. How it works I'll explain via this example. If we take
  the latest example and apply it to this table it will not display
  in:2 It goes through a for loop that repeats for 2 times(the number
  of incoming units) with the price set to the unit price(5000) so you
  get two rows with this info In:1 Price:5000 Total:5000.</li>
  </ul>
  
  <p>What I'm afraid of is, If There's 2 units with the price of 5000 and 3 with the price of 6000 And I ask to take out 4 units. The main table will not take both prices and will only take the latest price. What I want to do is test the price in a for loop that checks the second table and goes through it when taking out products and if the price changes it breaks the loop, inserts the data that was collected before the break with the old price. go back to the loop and cycle through it again and insert the new collected data with the new price. I'm so sorry I know it's complicated but this is as much simplification as I can. What I can't do currently is that comparison between the prices so the loop breaks when the price changes and then comes back. The thing I want is simple but I needed to explain everything so you have a general idea. </p>
  
  <p>Thanks</p>