jeddi
01-25-2010, 01:09 PM
I am stepping through a table and I want to update one
records of the current row if there is a condition met.
Is it allowable to updtae the current row?
Or is there an automatic record lock that would prevent it ?
$sql = "SELECT * FROM cb_update ORDER BY id";
$result = mysql_query($sql)
or die("could not OPEN CB_update.". mysql_error());
while($row = mysql_fetch_assoc($result)){
extract($row);
if( $mgrav != $grav) {
$new_data = 'y';
$grav_chg =$grav-$mgrav;
$sql_spc = "UPDATE cb_update SET grav_chg = '$grav_chg' WHERE cb_id = '$cb_id' ";
$result = mysql_query($sql) or die("could not UPDATE cb_update .". mysql_error());
}
}
If I am not able to do it this way, then I will have to save the row
id numbers and go back to make the changes when the while loop has ended.
Does anyone know what I should do ?
Thanks.
records of the current row if there is a condition met.
Is it allowable to updtae the current row?
Or is there an automatic record lock that would prevent it ?
$sql = "SELECT * FROM cb_update ORDER BY id";
$result = mysql_query($sql)
or die("could not OPEN CB_update.". mysql_error());
while($row = mysql_fetch_assoc($result)){
extract($row);
if( $mgrav != $grav) {
$new_data = 'y';
$grav_chg =$grav-$mgrav;
$sql_spc = "UPDATE cb_update SET grav_chg = '$grav_chg' WHERE cb_id = '$cb_id' ";
$result = mysql_query($sql) or die("could not UPDATE cb_update .". mysql_error());
}
}
If I am not able to do it this way, then I will have to save the row
id numbers and go back to make the changes when the while loop has ended.
Does anyone know what I should do ?
Thanks.