如何将变量从一个表传递到另一个表 [英] how to pass a variable from one table to another
问题描述
大家好,
我有以下代码(部分内容):
< pre lang =PHP> $ query = INSERT INTO eyfs_register(register_id,am,pm, student_info_id )
VALUES(:register_id,:am,:pm, :student_info_id )跨度>;
$ statement = $ conn-> prepare($ query);
// 学生详细信息表
$ statement-> bindValue( :register_id,$ register_id);
$ statement-> bindValue( :am,$ am);
$ statement-> bindValue( :pm,$ pm);
$ statement-> bindValue( :student_info_id, $ student_info_id);
$ statement-> execute();
$ conn-> commit();
学生信息ID以粗体显示,是不是表单中的用户输入。它显示为从另一个表中读取的文本。问题是在这个eyfs_register表中看到一个存在student_info_id的列并且是一个外键,我需要一个要插入的id的副本。
我知道它不能通过,因为变量将在表单中输入。我该怎么办?它只是表格中的一个简单行:
echo < span class =code-string>
< td>< h3>。 $ row [' student_info_id']。 < / h3>< / td>;
query = INSERT INTO eyfs_register( register_id,am,pm, student_info_id )
VALUES(:register_id,:am,:pm, :student_info_id )跨度>;
statement =
conn->制备(
hi all,
I have the following code (part of it):
$query = "INSERT INTO eyfs_register (register_id, am, pm, student_info_id)
VALUES (:register_id, :am, :pm, :student_info_id)";
$statement = $conn->prepare($query);
//student details table
$statement->bindValue(":register_id", $register_id);
$statement->bindValue(":am", $am);
$statement->bindValue(":pm", $pm);
$statement->bindValue(":student_info_id", $student_info_id);
$statement->execute();
$conn->commit();
the student info id which is in bold, is not a user input within the form. it is displayed as text read from another table. the question is as seen as in this eyfs_register table a column with student_info_id exists and is a foreign key, i need a copy of the id to be inserted.
I know it cannot be passed through as a variable would be which is input in a form. How would i do it? it is just a simple row within the form :
echo "<td><h3>" . $row['student_info_id'] . "</h3></td>";
query = "INSERT INTO eyfs_register (register_id, am, pm, student_info_id) VALUES (:register_id, :am, :pm, :student_info_id)";
statement =
conn->prepare(
这篇关于如何将变量从一个表传递到另一个表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!