How to add a form to a table and submit a MySQL database

Source: Internet
Author: User
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 "















"; $sql =" SELECT architecture, profit amount from ' org ' WHERE supervisor number = ' ". $q." ' "; $result = mysql_query ($sql), while ($row = Mysql_fetch_array ($result)) {echo ' "; echo " "; echo " "; } echo "
Architecture Profit Amount
" . $row [' Schema ']. "
";

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 ']. "'";
  • 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.