Update data from Php:
In this tutorial we are show the table value can be update from old one to new one.In this example name in the field value henry will changed to the mathavan
Syntax:
update table_name set attri_name='value' where
attr_value='value to be changed'
this syntax for update value in table
<?php
$conn=mysql_connect("localhost","root","");
$sel=mysql_select_db("proj",$conn);
$c
= mysql_query("select * from data");
echo
"<table border='1'>";
echo
"<tr><td>name</td><td>Last
name</td><td>Address</td><td>Email
id</td> <td>Phone</td></tr>";
while($fetch
= mysql_fetch_array($c))
{
echo
"<tr><td>$fetch[0]</td><td>$fetch[1]</td><td>$fetch[2]</td><td>$fetch[3]</td><td>$fetch[4]</td></tr>";
}
echo
"</table>";
$q=mysql_query("update
data set name='mathavan' where name='kenry'");
if($q)
{
echo"update";
}
$c
= mysql_query("select *from data");
echo
"after updating";
echo
"<table border='1'>";
echo
"<tr><td>name</td><td>Last
name</td><td>Address</td><td>Email
id</td><td>Phone</td></tr>";
while($row
= mysql_fetch_array($c))
{
echo
"<tr><td>$row[0]</td><td>$row[1]</td><td>$row[2]</td><td>$row[3]</td><td>$row[4]</td></tr>";
}
echo
"</table>";
?>
Output:
Post a Comment