Update data record and get the affected rows
<html>
<body>
<?php
$host="mysql153.secureserver.net";
$uname="java2s";
$pass="password";
$database="java2s";
$tablename="Employee";
$connection= mysql_connect($host,$uname,$pass) or die("Database connection failed!<br>");
$result=mysql_select_db($database) or die("Database could not be selected");
$query = "UPDATE Employee SET Firstname=\"new Name\" where id=2";
$result = mysql_query($query);
if (!$result) {
die(" Query could not be executed.<br>");
} else {
echo "<table> ";
echo " <tr>";
echo " <td colspan=\"2\">";
echo " <center><b>".mysql_affected_rows()." record updated successfully</b></center>";
echo " </td>";
echo " </tr>";
echo " <tr>";
echo " <td>";
echo " <div align=\"right\"> Name</div>";
echo " </td>";
echo " <td>".$name. "</td>";
echo " </tr>";
echo " <tr>";
echo " <td>";
echo " <div align=\"right\">E-mail</div>";
echo " </td>";
echo " <td>".$email. "</td>";
echo " </tr>";
echo " <tr>";
echo " <td>";
echo " <div align=\"right\"> CustomerID</div>";
echo " </td>";
echo " <td>".$customerid. "</td>";
echo " </tr>";
echo "</table>";
}
?>
</body>
</html>
Related examples in the same category