Which is more ideal for updating each row at a time in a MySQL database?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

can anyone recommend which of these is better for loading and updating one row at a time in a MySQL database?

for()
foreach()
while()
if...then()

other...?

What I am trying to do is make a PHP code open a table in a MySQL database, then it loads the information needed like Column 1 and Column 2 for example.


Such as:

Column 1 has 20 in one row and 15 in the next, Column 2 has 0 in both rows.

What I got it to do is to subtract one value from Column 1 and add a value to Column 2.

So after running this script once, it will end up as Column 1 having 19 for the first row and 14 for the row below it. And both rows in Column 2 having 1 in each.

The problem starts when I try updating the database, rather than saving one at a time in each database it will replace all other rows with the first one loaded. So instead of row 2 having 14 it will have the same as the first row, which is 19.


Thanks to Ross and hubo for the cookie advice, I have managed to get it working fine.

If you can recommend anything that can get my one step closer to getting this script to parse successfully then it will be a great help,

Many thanks again,

Dan

[Index of Archives]     [PHP Home]     [PHP Users]     [PHP Database Programming]     [PHP Install]     [Kernel Newbies]     [Yosemite Forum]     [PHP Books]

  Powered by Linux