PHP: Updating Record Within A While Loop - Programming - Nairaland
Nairaland Forum › Science/Technology › Programming › PHP: Updating Record Within A While Loop (1134 Views)
1 Reply
| PHP: Updating Record Within A While Loop by uvalued(op): 3:37pm On May 02, 2016 |
Hello guys, I need your support with respect to the code below.. The logic is this, Get the id,fin from a table called entry then add 1 to fin and update the fin column with fin=fin+1. It does for the first row but stops. I want all the fin column updated with fin=fin+1 where id = 1,2,3,4 etc <?php |
| Re: PHP: Updating Record Within A While Loop by spikesC(m): 6:08pm On May 02, 2016*. Modified: 2:44pm On May 03, 2016 |
1. There's no need to perform the first query. Any SELECT query returns the num_of_rows 2. Don't run queries in loops. Build the query string in the loop and run the query after looping 3. I don't know where the variable $session comes from Finally, your solution. A single query would actually solve your problem. UPDATE entry SET fin = fin+1 Yep, Just that. |
| Re: PHP: Updating Record Within A While Loop by uvalued(op): 8:50pm On May 02, 2016 |
spikesC:thanks a alot... simply doing UPDATE entry SET fin = fin+1 in phpmyadmin did the trick... thanks |
Javascript - While Loop • Help With Python Program (simple While Loop) • Programming Challenge: Convert String to Json with a Loop • 2 • 3 • 4
Learn Programming Or Pay A Programmer • Ekiti State Uni. Mobile App • Classy Business Website For A Microfianace Bank