同じデータベースの下にあるテーブルの 1 つから選択したデータを挿入したいと考えています。コードはありますが、機能しません。
モジュールインデックス.php
<?php
include "connectdatabase.php";//include the connection file
$db = mysql_select_db("section_masterfile",$connectDatabase);
$queries = "Select student_Firstname, student_Lastname, student_Section FROM masterfile_table";
if(isset($_POST['TeacherName'])&& isset($_POST['SectionName']))
{
$searchTeacher = $_POST['TeacherName'];
$searchSection = $_POST['SectionName'];
$queries = "Select student_Firstname, student_Lastname, student_Section FROM masterfile_table WHERE section_Teacher = '{$searchTeacher}' AND student_Section='{$searchSection}'";
}
$queried = mysql_query($queries,$connectDatabase);
?>
insertdata.php
<?php
include 'moduleindex.php';
include 'connectdatabase.php';
$db_pdf = mysql_select_db("section_masterfile",$connectDatabase);
while($row = mysql_fetch_array($queried))
{
$field1 = $row['student_Lastname'];
$field2 = $row['student_Firstname'];
$field3 = $row['student_Section'];
$insert_query = mysql_query("INSERT INTO pdf_table (student_Lastname,student_Firstname,student_Section) VALUES ('{$field1}', '{$field2}', '{$field3}')",$connectDatabase);
}
?>