phprockers-logo

Update query in mysql

The syntax for Update the row into tables,

UPDATE
    table_name SET (colname1, colname2, colname3 ...) VALUES (value1,value2,value3,...) WHERE colname = row_values;   

<?php

$con = mysql_connect('localhost', 'root','');
mysql_select_db('dbname', $con) or die(mysql_error());

$query = "UPDATE table_name SET rank="2" WHERE sno = 2";   
$ok = mysql_query($query);

if($ok)
echo "Updated row successfully";
else
echo "Failed to update the row in the table";

?>


sno name marks rank post_of_date
2 krishnan 397 2 09-04-2001
3 PHP Developer 521 36 27-03-2012

0 comments:

Post a Comment