Hi all,
I thought I had a result with a previous thread, but I was wrong.
I am trying to UPDATE multiple rows in a table with different data. This is what I am working with:
mysql_select_db($database_flightdata, $flightdata);
$query_flightdata = "SELECT cd.flightid, cd.flightstatus, fd.id, fd.stat FROM flight_client cd , flightdata fd WHERE cd.flightid = fd.id ";
$flightdata = mysql_query($query_flightdata, $flightdata) or die(mysql_error());
while ( $row = mysql_fetch_assoc( $flightdata ) ) {
$stat = empty( $row_flightdata['stat'] )? 'NULL' : $row_flightdata['stat']; // make sure this stat havea value
$sql = "UPDATE flight_client SET flightstatus=".$row['stat']." WHERE " . $row['id'] . " = " . $row['flightid'] ;
echo "$sql<br />"; // test the last one and the first one in phpmyadmin...
// mysql_query($sql) or die(mysql_error());
}
$totalRows_flightdata = mysql_num_rows($flightdata);
When I run the script the output is:
UPDATE flight_client SET flightstatus=11 WHERE 170 = 170
UPDATE flight_client SET flightstatus=14 WHERE 188 = 188
UPDATE flight_client SET flightstatus=9 WHERE 200 = 200
But the table I am trying to UPDATE is not getting updated.
Can anyone see where I am going wrong.