How PHP modifies data in the database according to the specified ID

Source: Internet
Author: User
How PHP modifies data in the database according to the specified ID
$query = mysql_query (' SELECT * from Wdksm ');
while ($row = Mysql_fetch_assoc ($query))
{{
$id = $row [' id '];
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 '
';
}
$sql = ' UPDATE wdksm SET
Rsshtime = \ '. $_post[' Test ']. '\'
WHERE id = \ '. $id. '\' ';
mysql_query ($sql);

?>


Reply to discussion (solution)

ID is the number do not add ' '?

Your UPDATE statement is not going to execute? Looks fine.

Update your table name set the column name to change = the value to change where id = the ID number you specified

If I follow the data listed above, point out the audit under each data, the data "audit" will be written to the current data, and now write the data are written by default to the bottom of the data inside the

That's how your form is created.

Echo ';
There is no value for ID
So the submitted data does not contain a unique identification ID

And the ID in your SQL instruction is the last ID when the list was generated, and of course it's not.

Besides, your SQL command's writing is weird, too.
It's better to write like this
$sql = "UPDATE wdksm SET rsshtime = ' $_post[test] ' WHERE id = ' $_post[id] '";

$sql = "UPDATE wdksm SET rsshtime = ' $_post[test] ' WHERE id = ' $_post[id] '";
This code is put in not even write, I need to choose an ID, and write the data into this ID, do not affect the data of other IDs

while ($row = Mysql_fetch_assoc ($query))
{
$id = $row [' id '];
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 '


';
}

while ($row = Mysql_fetch_assoc ($query))
{
$id = $row [' id '];
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 '


';
}

The elder brother upstairs, according to your line of code to add in also not AH
  • Related Article

    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.