Jump to content

PHP MYSQL update 2 fields


perezf

Recommended Posts

I need help on updating two fields from a MySQL database through the use of a form

I need it to update the heading field, and information field

but all it does is add a new field  Can someone please help me :)

 

This is for the form

<form id="form1" name="form1" method="post" action="pageupdate.php">
  <label>
  <input type="radio" name="radio" id="mainpage" value="mainpage" />
  Main Page   </label>
  <label>
  <input type="radio" name="radio" id="ourmission" value="ourmission" />
  Our Mission Page
     
  <input type="radio" name="radio" id="contactus" value="contactus" />
  Contact Us Page</label>
  <p>Heading:<br />
    <input name="heading" type="text" id="heading" size="50" />
  </p>
  <p>Information:   <br />
    <textarea name="information" cols="60" rows="20" id="information"></textarea>
  </p>
  <p>
    <input type="submit" name="Submit" value="Edit Page" />
  </p>
</form>

 

This is for the php update

<?php

$heading = $_POST['heading'];
$information = $_POST['information'];
$radio = $_POST['radio'];

include('dbconnect.php');

mysql_query("INSERT INTO $radio (heading,information) VALUES ('$heading','$information')");


?>

Link to comment
https://forums.phpfreaks.com/topic/52154-php-mysql-update-2-fields/
Share on other sites

I figured it out Thanks guys :)

<?php

$heading = $_POST['heading'];
$information = $_POST['information'];
$radio = $_POST['radio'];

include('dbconnect.php');

mysql_query("UPDATE $radio SET heading = '$heading' WHERE heading = heading");
mysql_query("UPDATE $radio SET information = '$information' WHERE information = information");


?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.