How to add a form to a table and submit a MySQL database
I am a novice, now want to do an indicator submission system, MySQL database has the overall structure of sales, and has been in PHP in accordance with the login account automatically generated corresponding sales subordinates, but the structure followed by sales indicators, want to make an input box, and submit to the database, how to do:
Architecture Profit Amount
-L4: Shanghai Wedding yellow supervisor Input Box
-L3: Shanghai Wedding 2 Group Shen Supervisor Input Box
-L2: Shanghai wedding 2-1 Group MA supervisor Input Box
L1: Sun Sales Input box
L1: Du sales input box
L1: Lee Sales input box
$q =$_post["EmployeeNumber"];
$con = mysql_connect (' localhost ', ' root ', ');
if (! $con)
{
Die (' Could not connect: '. Mysql_error ());
}
mysql_select_db ("org", $con);
echo "
Architecture |
Profit Amount |
"; $sql =" SELECT architecture, profit amount from ' org ' WHERE supervisor number = ' ". $q." ' "; $result = mysql_query ($sql), while ($row = Mysql_fetch_array ($result)) {echo '
"; echo "
" . $row [' Schema ']. " | "; echo "
"; } echo "
";
Mysql_close ($con);
?>
------to solve the idea----------------------
I've changed it on your basis, and that's how it's thought to be submitted with the ID of the table record.
index.php
$q =$_post["EmployeeNumber"];
$con = mysql_connect (' localhost ', ' root ', ');
if (! $con)
{
Die (' Could not connect: '. Mysql_error ());
}
mysql_select_db ("org", $con);
Mysql_close ($con);
?>
add.php
$con = mysql_connect (' localhost ', ' root ', ');
if (! $con)
{
Die (' Could not connect: '. Mysql_error ());
}
mysql_select_db ("org", $con);
$employeenumber = $_post["EmployeeNumber"];
$sql = "Select ID, schema, profit amount from ' org ' WHERE supervisor number = '". $q. "'";
$result = mysql_query ($sql);
while ($row = Mysql_fetch_array ($result))
{
if ($_post[' yl '. $row [' ID ']]) {
$SQLSTR = "Update ' org ' set Profit = '". $_post[' yl '. $row [' ID ']]. "' Where id= '". $row [' id ']. "'"; Update into DB
mysql_query ($sqlstr) or Die (Mysql_error ());
}
}
Mysql_close ($con);
Header (' location:index.php?q= '. $employeenumber); Jump back.
?>
------to solve the idea----------------------
24 Lines of
Profit amount = ' "$_post[' yl '. $row [' ID '].]" ' where
Switch
Profit amount = ' ". $_post[' yl '. $row [' ID ']]." ' Where
------to solve the idea----------------------
This post was last edited by xuzuning on 2014-12-10 18:33:58
$SQLSTR = "Update ' org ' set profit = '" $_post[' yl '. $row [' ID '].] "' Where id= '". $row [' id ']. "'";
should be
$SQLSTR = "Update ' org ' set Profit = '". $_post[' yl '. $row [' ID ']]. "' Where id= '". $row [' id ']. "'";