Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8425981
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T04:25:27+00:00 2026-06-10T04:25:27+00:00

I have a problem updating an MySQL Database. I want to be able to

  • 0

I have a problem updating an MySQL Database. I want to be able to update a chart (MySQL Database) as more information comes in, the employees at my firm do not fill in all the information all at once and fill in this chart as more information comes in.

Here is my code:

<?php
//retrieve our data from POST
$ID = $_POST['ID'];
$Date_Received = $_POST['DateReceived'];
$Mortgagee_Vendor = $_POST['Mortgagee'];
$Mortgagor_Purchaser = $_POST['Mortgagor'];
$We_Act_For = $_POST['WeActFor'];
$Amount = $_POST['Amount'];
$Full_Address = $_POST['FullAddress'];
$Lot = $_POST['Lot'];
$Plan = $_POST['Plan'];
$Municipality = $_POST['Municipality'];
$Solicitor = $_POST['Solicitor'];
$Closing_Date = $_POST['ClosingDate'];
$Has_Union = $_POST['Union'];
$Lawyer_Clerk = $_POST['LawyerClerk'];
$Date_File_Opened = $_POST['FileOpened'];
$Search_Date = $_POST['Search'];
$Requisition_Date = $_POST['ReqDate'];
$Requisition_Sub = $_POST['ReqSubmittedReplied'];
$Mortgage_Inst = $_POST['MortgageInst'];
$Appointment_Date = $_POST['AppDate'];
$Payout_Req_Sent = $_POST['PayoutSent'];
$Payout_Req = $_POST['PayoutRequest'];
$Requisition_Recieved = $_POST['ReqReceived'];
$Draft_Deed = $_POST['DraftDeed'];
$Report_Letter = $_POST['ReportLetter'];
$Undertakings = $_POST['Undertakings'];
$File_Closed = $_POST['FileClosed'];
$Special_Notes = $_POST['SpecialNotes'];
$Deal_Active = $_POST['DealActive'];

//connect to database    
$dbhost = 'localhost';
$dbname = 'database';
$dbuser = 'user';
$dbpass = 'Password'; 
$conn = mysql_connect($dbhost, $dbuser, $dbpass);
mysql_select_db($dbname, $conn);

//sanitize all fields

$ID = mysql_real_escape_string($ID); 
$Date_Received = mysql_real_escape_string($Date_Received);
$Mortgagee_Vendor = mysql_real_escape_string($Mortgagee_Vendor);
$Mortgagor_Purchaser = mysql_real_escape_string($Mortgagor_Purchaser);
$We_Act_For = mysql_real_escape_string($We_Act_For);
$Amount = mysql_real_escape_string($Amount);
$Full_Address = mysql_real_escape_string($Full_Address);
$Lot = mysql_real_escape_string($Lot);
$Plan = mysql_real_escape_string($Plan);
$Municipality = mysql_real_escape_string($Municipality);
$Solicitor = mysql_real_escape_string($Solicitor);
$Closing_Date = mysql_real_escape_string($Closing_Date);
$Has_Union = mysql_real_escape_string($Has_Union);
$Lawyer_Clerk = mysql_real_escape_string($Lawyer_Clerk);
$Date_File_Opened = mysql_real_escape_string($Date_File_Opened);
$Search_Date = mysql_real_escape_string($Search_Date);
$Requisition_Date = mysql_real_escape_string($Requisition_Date);
$Requisition_Sub = mysql_real_escape_string($Requisition_Sub);
$Mortgage_Inst = mysql_real_escape_string($Mortgage_Inst);
$Appointment_Date = mysql_real_escape_string($Appointment_Date);
$Payout_Req_Sent = mysql_real_escape_string($Payout_Req_Sent);
$Payout_Req = mysql_real_escape_string($Payout_Req);
$Requisition_Recieved = mysql_real_escape_string($Requisition_Recieved);
$Draft_Deed = mysql_real_escape_string($Draft_Deed);
$Report_Letter = mysql_real_escape_string($Report_Letter);
$Undertakings = mysql_real_escape_string($Undertakings);
$File_Closed = mysql_real_escape_string($File_Closed);
$Special_Notes = mysql_real_escape_string($Special_Notes);
$Deal_Active = mysql_real_escape_string($Deal_Active);

//insert values to mysql database
mysql_query("UPDATE `all_info` SET `Date Received` = '$Date_Received', `Deal Active` = '$Deal_Active', `Mortgagee/Vendor` = '$Mortgagee_Vendor', `Mortgagor/Purchaser` = '$Mortgagor_Purchaser', `We Act For` = '$We_Act_For', `Amount` = '$Amount', `Full Address` = '$Full_Address', `Lot` =  '$Lot', `Plan` = '$Plan', `Municipality` = '$Municipality', `Solicitor` = '$Solicitor', `Closing Date` = '$Closing_Date', `Lawyer/Clerk` = '$Lawyer_Clerk', `File Opened` = '$Date_File_Opened', `Search Date` = '$Search_Date', `Requisition Date` = '$Requisition_Date', `Requisition Submitted/Replied` = '$Requisition_Sub', `Mortgage Instructions Received` = '$Mortgage_Inst', `Appointment Date for Clients` = '$Appointment_Date', `Pay Out Request Sent` = '$Payout_Req_Sent', `Payout/Funding Sent`= '$Payout_Req', `Requisition Received` = '$Requisition_Recieved', `Draft Deed/Adjustment Sent` = '$Draft_Deed', `Reporting Letter` = '$Report_Letter', `Undertaking Satisfied` = '$Undertakings', `File Closed` = '$File_Closed', `Special Notes` = '$Special_Notes' WHERE ID = '$ID'");





echo mysql_error();     

mysql_close();

?>

So basically, when a user creates the row (using separate script) he/she will fill in “some” of the post entries. My main problem is when entries exist, they are replaced with blank post submission. I need MySQL to ignore these “blank” post entries and not replace data that exists.

EDIT: with the help of arxanas I was able to come up with this code, this is the final product with working code.

<?php
$ID = $_POST['ID'] 
$Date_Received = $_POST['DateReceived'];
$Mortgagee_Vendor = $_POST['Mortgagee'];
$Mortgagor_Purchaser = $_POST['Mortgagor'];
$We_Act_For = $_POST['WeActFor'];
$Amount = $_POST['Amount'];
$Full_Address = $_POST['FullAddress'];
$Lot = $_POST['Lot'];
$Plan = $_POST['Plan'];
$Municipality = $_POST['Municipality'];
$Solicitor = $_POST['Solicitor'];
$Closing_Date = $_POST['ClosingDate'];
$Has_Union = $_POST['Union'];
$Lawyer_Clerk = $_POST['LawyerClerk'];
$Date_File_Opened = $_POST['FileOpened'];
$Search_Date = $_POST['Search'];
$Requisition_Date = $_POST['ReqDate'];
$Requisition_Sub = $_POST['ReqSubmittedReplied'];
$Mortgage_Inst = $_POST['MortgageInst'];
$Appointment_Date = $_POST['AppDate'];
$Payout_Req_Sent = $_POST['PayoutSent'];
$Payout_Req = $_POST['PayoutRequest'];
$Requisition_Recieved = $_POST['ReqReceived'];
$Draft_Deed = $_POST['DraftDeed'];
$Report_Letter = $_POST['ReportLetter'];
$Undertakings = $_POST['Undertakings'];
$File_Closed = $_POST['FileClosed'];
$Special_Notes = $_POST['SpecialNotes'];
$Deal_Active = $_POST['DealActive'];

// connect to database
$dbhost = 'localhost';
$dbname = 'dbname';
$dbuser = 'user';
$dbpass = 'pass'; 
$conn = mysql_connect($dbhost, $dbuser, $dbpass);
mysql_select_db($dbname, $conn);

$fields = array(
    "ID" => "ID",
    "Date Received" => "DateReceived",
    "Mortgagee/Vendor" =>"Mortgagee",
    "Mortgagor/Purchaser" => "Mortgagor",
    "We Act For" => "WeActFor",
    "Amount" => "Amount",
    "Full Address" => "FullAddress",
    "Lot" => "Lot",
    "Plan" => "Plan",
    "Municipality" => "Municipality",
    "Solicitor" => "Solicitor",
    "Closing Date" => "ClosingDate",
    "Union" => "Union",
    "Lawyer/Clerk" => "LawyerClerk",
    "File Opened" => "FileOpened",
    "Search Date" => "Search",
    "Requisition Date" => "ReqDate",
    "Requisition Submitted/Replied" => "ReqSubmittedReplied",
    "Mortgage Instructions Received" => "MortgageInst",
    "Appointment Date for Clients" => "AppDate",
    "Pay Out Request Sent" => "PayoutSent",
    "Payout/Funding Sent" => "PayoutRequest",
    "Requisition Received" => "ReqReceived",
    "Draft Deed/Adjustment Sent" => "DraftDeed",
    "Reporting Letter" => "ReportLetter",
    "Undertaking Satisfied" => "Undertakings",
    "File Closed" => "FileClosed",
    "Special Notes" => "SpecialNotes",
    "Deal Active" => "DealActive",    

);
$update = array();
foreach ($fields as $column => $field) {
    if (isset($_POST[$field]) && strlen($_POST[$field])) {
        $update[] = "`".$column."` = '".mysql_real_escape_string($_POST[$field])."'";
    }
}
$sql = "UPDATE `all_info` SET ".implode(", ", $update)."WHERE ID = '$ID'";
mysql_query($sql);

echo mysql_error();
echo "<br><br><center>Table Sucessfully Updated</center>";      

mysql_close();

?> 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T04:25:28+00:00Added an answer on June 10, 2026 at 4:25 am
    $fields = array(
        "ID" => "ID",
        "Date Received" => "DateReceived",
        "Mortgagee/Vendor" =>"Mortgagee",
        ...
    );
    $update = array();
    foreach ($fields as $column => $field) {
        if (isset($_POST[$field]) && strlen($_POST[$field])) {
            $update[] = "`".$column."` = '".mysql_real_escape_string($_POST[$field])."'";
        }
    }
    $sql = "UPDATE `all_info` SET ".implode(", ", $update)."WHERE ID = '$ID'";
    mysql_query($sql);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am struggling to update my MySQL database. This is what I have written:
Question solved... silly mistake i have a little problem with my database update script
I want to update data from my database using java. I have established my
I am having problem with updating data to database. I have a simple many-to-one
Have a problem with updating an existing record of my DB. In my view
i have a problem with updating my textview. i am making a c2dm app.
I have a little problem in updating date. My first table is DONOR donor-nic----username-----status
I have problem SIMILAR to preventing form data reposting, but not quite the same
I have a database which is updating values, which are positions of an opponent
We're having mysterious network problems with MySQL. Simple update query (updating single row using

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.