this can be done when only one record in the table, if more than one record in the table, it show the error message.
Warning: Supplied argument is not a valid MySQL result resource in c:\phpweb/test5.php on line 6
how can i change this code to select the first row first, run the script, and then select the second row, run the scriptand so on.
then update the the different result in different rows.
+-------+------+------+
| User | Year | Days |
+-------+------+------+
| Ken | 2002 | 5 |
| Peter | 2003 | 9 |
+-------+------+------+
<?
$query = "SELECT Year, Days FROM user";
$result = mysql_query($query);
while($row = mysql_fetch_array($result))
{
$CurrentYear = date("Y");
$Diff = $CurrentYear - $Year;
$Year = $row['Year'];
$Days = $row['Days'];
if ($Diff <= 2){
$Year = $Year + 1;
$result = mysql_query("UPDATE user SET Year=$Year");
}
.
.
.
.
.
}
?>