Page 1 of 1

Creating a loop to update DB IDs

Posted: Fri Sep 22, 2006 8:28 am
by impulse()
I have a DB with a log file of all connections entering my website. From testing on this I have ran 'php <file>' from a console which has caused blank entries in the table and then genuine data has been added and I've now deleted these blank lines which has left a bad increment of the IDs eg - 1, 2, 3, 5, 6, 7.
What function is there in PHP to edit data on a certain row in the database and not where certain data is equal to something on any row. I want to go though:

A) Update row 1 ID with <variable>
B) Update row 2 ID with <variable + 1>
etc etc

I can do the looping I just don't know how to select certain rows.

Can someone point me in the right direction please.

Regards, Stephen

Posted: Fri Sep 22, 2006 11:50 am
by feyd
A select query with a WHERE clause.

Posted: Fri Sep 22, 2006 1:34 pm
by impulse()
How do I do a WHERE rownumber = $i?

Posted: Fri Sep 22, 2006 1:56 pm
by feyd
You don't. Either use specifics for that row or store the results that would select all of the records you want to iterate over into an array before processing.