|
Added on 15.11.09 |
| Clicks 1649 |
| Rating: 4.50 out of 5 from 2 raters |

We have a table with a row like this one:
Advanced Database Technology and
Design, Mario Piattini and Oscar Diaz, Database, 89
If we have to
change the price of$ 89 to 95.20 $ for example,all we do is just a piece of
code like the following
The above code, if succeds, return 1 as the row effected by the code is
1,or else return false and it will stop and print an error message.
The only difference from inserting is this part
$sql="UPDATE books
SET price = '$ 95,2' WHERE id=11" ;
$result = mysql_query($sql);
if (!$result) {
die('Invalid query: ' . mysql_error());
}
$rows_affected
=mysql_affected_rows();
echo $rows_affected;
The
$sql variable holds the sql statement
and the PHP function mysql_query($sql);
executes the command and the job is done