i got complete details in html table and willing to update 2 values

Recommended Answers

What exactly do you have?

Jump to Post

All 4 Replies

What exactly do you have?


You need a php code that updates db from a form like tis?

$action = isset( $_POST['action'] ) ? $_POST['action'] : "";
if($action == "update"){ 
$query = "update city
name = '".$con->real_escape_string($_POST['name'])."',
state = '".$con->real_escape_string($_POST['state'])."',
population = '".$con->real_escape_string($_POST['population'])."',
zipcode  = '".$con->real_escape_string($_POST['zipcode'])."',
area  = '".$con->real_escape_string($_POST['area'])."',
phone  = '".$con->real_escape_string($_POST['phone'])."',
fax  = '".$con->real_escape_string($_POST['fax'])."'    
where id_city='".$con->real_escape_string($_REQUEST['id'])."'";
if( $con->query($query) ) {
echo '<div class="alert alert-success">City was updated!</div>.';
echo '<div class="alert alert-danger">Database Error: Unable to update record.</div>';

Just a heads up, your question is abit bland, spice it up abit with some more detail! :)

Try this:

// Check connection
if (mysqli_connect_errno()) {
  echo "Failed to connect to MySQL: " . mysqli_connect_error();

mysqli_query($con,"UPDATE Persons SET Age=36
WHERE FirstName='Peter' AND LastName='Griffin'");

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.21 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.