Jump to content

[SOLVED] Small update problem


waynew

Recommended Posts

Hey guys. I have a small problem that I know somebody will probably solve in a second. I have a page for those who want to edit details about whatever company they choose. All details are stored in mySQL. Now, taking these values out an placing them in text areas like this:

 

echo "<input type=\"text\" name=\"county\" id=\"county\" value=\"".$cfg_counties[$countyNum]."\"><br/><br/>";

 

... isn't the problem. The problem also isn't to do with the mySQL update, which is working fine.

 

The problem is that if I don't change the data in a form, it is automatically changed to blank once I post the form.

 

Any ideas about how to get around this problem? Again, probably simple.

 

Thanks guys.

Link to comment
https://forums.phpfreaks.com/topic/110895-solved-small-update-problem/
Share on other sites

The update script is as follows:

 

if(isset($_POST['updating'])){ //check to see if user is updating

$new_company_name = $_POST['compname'];
$address_one = $_POST['address1'];
$address_two = $_POST['address2'];
$countyname = $_POST['county'];

$num = array_search($countyname,$cfg_counties); //uses array of counties and matches county to key for purpose of insertion.

mysql_query("UPDATE jobs SET company_name = '$new_company_name', address1 = '$address_one', address2 = '$address_two', county = '$num' WHERE company_name = '$company_name'");
}

 

 

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.