Code
$minus = mysql_query("SELECT * FROM dtr");
while($minusdata = mysql_fetch_array($minus, MYSQL_ASSOC))
{
$time = mysql_fetch_assoc(mysql_query("SELECT time_to_sec(timediff(time_out,time_in)) as x from dtr where dtr_id = dtr_id"));
$t = $time['x'];
mysql_query("UPDATE dtr SET diff = '$t' WHERE dtr_id = dtr_id AND time_out != '00:00:00'");
}
I know it should work. Select the timediff of 2 columns in each row then update it to a diff
column in that row. But what is happening is only the timediff of the first row is being updated to all diff
columns instead of the timediff in each respective row.
Example: the timediff of the first row is 5 so 5 is the data being updated to all diff columns in all rows.