connection.inc.php :
<?php
$host='localhost';
$user_name='root';
$password='';
@$con = mysql_connect("$host","$user_name","$password");
if ($con)
{echo '<br>host coonected<br>';}
else
{
die('Could not connect ');
}
?>
update_table.php :
<?php
require 'connection.inc.php';
if (mysql_select_db('test'))
if(mysql_query("update test set name='humans'where sno=1",$con))
{
$result=mysql_query("select * from test where name='humans'",$con);
echo "<br><table><tr><td>sno</td><td>name</td></tr>";
while($data = mysql_fetch_array($result))
{
echo "<tr><td>".$data['sno'] . "</td><td>" .$data['name']."</td></tr>";
}
echo "</table><br>data updated<br>";
}
else
{
echo '<br>data not updated :'.mysql_error().'<br>';
}
mysql_close($con);
?>
run " update_table.php "
output:
host coonected
data updated
<?php
$host='localhost';
$user_name='root';
$password='';
@$con = mysql_connect("$host","$user_name","$password");
if ($con)
{echo '<br>host coonected<br>';}
else
{
die('Could not connect ');
}
?>
update_table.php :
<?php
require 'connection.inc.php';
if (mysql_select_db('test'))
if(mysql_query("update test set name='humans'where sno=1",$con))
{
$result=mysql_query("select * from test where name='humans'",$con);
echo "<br><table><tr><td>sno</td><td>name</td></tr>";
while($data = mysql_fetch_array($result))
{
echo "<tr><td>".$data['sno'] . "</td><td>" .$data['name']."</td></tr>";
}
echo "</table><br>data updated<br>";
}
else
{
echo '<br>data not updated :'.mysql_error().'<br>';
}
mysql_close($con);
?>
run " update_table.php "
output:
host coonected
sno | name |
data updated