Hi
Apologies for serious newbie question! I'm an old Foxpro coder just getting to grips with php/mqsql...
So I have a simple table with 2 fields: ID (int) and NAME (varchar)
I'd like to loop through the table and update ID with an incrementing number each time.
I know how to get the number of rows using mysqli_num_rows, but not sure how to write the update statement. Can I do something like..?
for ($i=1;$i<=$rowcount;$i++)
{
$sql = "UPDATE mytable SET id=$i WHERE [I]row_number[/I]=$i";
$result = mysqli_query($cxn,$sql);
}
Not too worried about optimisation, as code only needs to be run once.
Thanks!