I have two tables: student table with the following fields:
And score table:
I want to insert into score table with a form with php.
I have retrieved form data and stored them in variables:
$math = $_POST ['math'];
$ biology = $_POST ['biology'];
$ physics = $_POST ['physics'];
Now how do I write the query to insert these data into database? I mean how d I fill value for field student_id which is a primary key.
What should I write instead of aaaa in the following query.
INSERT INTO score VALUES ('aaaa', '$ math', '$ biology', '$ physics');
You can store the student_id
in a hidden field in your HTML and access it in your $_POST
.
Just give the hidden field a name like name="hiddenStudentId"
and it will appear under $_POST["hiddenStudentId"]
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.