How to modify the contents of a table field in PHP

Source: Internet
Author: User
Rookie help How to change the contents of a field without changing the other fields, I would like to modify the ' Department Responsible person Audit: ' The contents of this field, but have not been written in
while ($row = Mysql_fetch_assoc ($query))
{
Echo ' Date: '. $row [time]. ' ';
Echo ' department: '. $row [bumen]. ' ';
Echo ' name: '. $row [name]. ' ';
Echo ' duties: '. $row [Zhiwu]. '
';
Echo ' No Clock out time: '. $row [wdktime]. '
';
Echo ' not clocked out reason: '. $row [Wdkyy]. '
';
Echo ' Department Responsible person audits: '. $row [bmshtime]. ' ';
Echo ' Personnel Administration department/General manager approves: '. $row [rsshtime]. '
';
Echo ' ';
Echo '
';
}
Echo ';
mysql_query (' UPDATE wdksm SET
Bmshtime = \ '. $_post[' Test ']. '\'
WHERE time = \ '. $row [id]. '\'
');


?>


Reply to discussion (solution)

What's wrong with this???

Note that the column name can be preceded by a try Plus '

Time = \ '. $row [id] ok? Not time = \ '. $row [TIME]?

Error at N.
The modified code is as follows:

$con =mysqli_connect (' localhost ', ' Database user name ', ' Database password ', ' database name '), $re =mysqli_query ($con, ' SELECT * from Wdksm ') and while ($row = MYSQLI_FETCH_ASSOC ($re)) {$id = $row [' id '];    Echo ' Date: '. $row [' time ']. '  ; Echo ' department: '. $row [' bumen ']. '  ; Echo ' name: '. $row ["name"]. "  ; Echo ' duties: '. $row ["Zhiwu"]. '
'; Echo ' clock-out time: '. $row ["Wdktime"]. '
'; Echo ' not clocked in: '. $row ["Wdkyy"]. '
'; Echo ' department Responsible person audits: '. $row ["Bmshtime"]. Echo ' Personnel Administration department/General manager approves: '. $row ["Rsshtime"]. '
'; Echo '
'; }echo '; $sql = ' UPDATE wdksm SET bmshtime = \ '. $_post[' Test '] . ' WHERE id = \ '. $id. "\"; Mysqli_query ($con, $sql);

Put the ' database username ', ' database password ', ' database name ' three items on the line. The rest is fine.

If you want a MySQL connection, you can use the following code to analyze your source codes:

$query = mysql_query (' SELECT * from Wdksm '), while ($row = Mysql_fetch_assoc ($query)) {$id = $row [' id '];            If the ID number you want to modify is not taken, you should get the echo ' Date: '. $row ["Time"].  Echo ' department: '. $row ["Bumen"]. "  ; Echo ' name: '. $row ["name"]. "  ; Echo ' duties: '. $row ["Zhiwu"]. '
'; Echo ' clock-out time: '. $row ["Wdktime"]. '
'; Echo ' not clocked in: '. $row ["Wdkyy"]. '
'; Echo ' department Responsible person audits: '. $row ["Bmshtime"]. Echo ' Personnel Administration department/General manager approves: '. $row ["Rsshtime"]. '
';//echo ''; The Submit button is placed outside the form, causing the form to fail to submit echo '
'; }echo ';/*mysql_query (' UPDATE wdksm SET bmshtime = \ '. $_post[' test ') . ' WHERE time = \ '. $row [id]. ' \ ' ///Critical Error SQL statement '); *///correct SQL statement $sql= ' UPDATE wdksm SET bmshtime = \ '. $_post[' Test '. ' WHERE id = \ '. $id. "\"; mysql_query ($sql);


The result of the implementation is the successful revision of the ' Department responsible person audit '.

Mainly the problem of SQL statements, single quotes, double quotation marks must be distinguished, there is a database of the type of fields, and some need to add quotation marks can not be less

It's ready to use, thanks.

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.