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.