Update query in php


mysql update
that you have a MySQL table that holds the data of the considerable number of representatives in your organization. One of the segments in this table is called "Status" and it holds a number estimation of how long a representative has functioned at your organization. Shockingly for you, your activity is to refresh these numbers each month.


  • UPDATE - Performs an update MySQL query
  • SET - The new values to be placed into the table follow SET
  • WHERE - Limits which rows are affected


PHP & MySQL Code:

<?php
// Connect to MySQL

// Get Sandy's record from the "example" table
$result = mysql_query("UPDATE example SET age='22' WHERE age='21'") 
or die(mysql_error());  


$result = mysql_query("SELECT * FROM example WHERE age='22'") 
or die(mysql_error());  

// get the first (and hopefully only) entry from the result
$row = mysql_fetch_array( $result );
echo $row['name']." - ".$row['age']. "<br />";
?>

Display:

Sandy Smith - 22
Share on Google Plus

About It E Research

This is a short description in the author block about the author. You edit it by entering text in the "Biographical Info" field in the user admin panel.
    Blogger Comment
    Facebook Comment

0 comments:

Post a Comment