从现有查询插入数据。为什么它不出现?

时间:2014-01-21 09:50:17

标签: php mysql mysqli

我需要将值插入到数据库中的匹配表中。但是值没有显示。出了什么问题?

$result = mysqli_query($con, "SELECT name, job_title, no_of_vacancy, assigned FROM student_details, job_details WHERE student_details.jobscope1 = job_details.jobscope AND student_details.jobscope1 = 'IT';");
$row = mysqli_fetch_assoc($result);

while($row = mysqli_fetch_assoc($result))
{ 

    $student = $row['name'];
    $company = $row['job_title'];
    $vacancy = $row['no_of_vacancy'];
    $assigned= $row['assigned'];


    if ($vacancy == $assigned) {

        $result2 = mysqli_query($con, "INSERT INTO matching (name, job_title) VALUES ('$student','$company') FROM student_details,job_details WHERE student_details.jobscope1 = job_details.jobscope AND student_details.jobscope1 = 'IT';");
        $row2 = mysqli_fetch_assoc($result2);


        $result3 = mysqli_query($con, "SELECT * FROM matching;");
        $row3 = mysqli_fetch_assoc($result3);

        echo    "<table border='1'>
                <tr>
                <th>Student</th>
                <th>Company</th>
                </tr>";

        while($row3= mysqli_fetch_assoc($result3)) {

        echo "<tr>";
        echo "<td>" . $row3['name'] . "</td>";
        echo "<td>" . $row3['job_title']. "</td>";
        echo "</tr>";

}}}

?>

0 个答案:

没有答案