Php Mysql匹配web

Php Mysql匹配web,php,html,mysql,web,Php,Html,Mysql,Web,我有一个数据库,表student(ID Primary)、student location作为字段,还有一个雇主表location。我想将雇主的位置与学生的位置匹配,复制学生id并将其粘贴到雇主的表中,其中学生位置=雇主的位置。我有以下代码 表格: 学生证 <th style='border: solid 1px black;'>Field Of Study</th> <th style='border: solid 1px black;'>L

我有一个数据库,表student(ID Primary)、student location作为字段,还有一个雇主表location。我想将雇主的位置与学生的位置匹配,复制学生id并将其粘贴到雇主的表中,其中学生位置=雇主的位置。我有以下代码

表格: 学生证

    <th style='border: solid 1px black;'>Field Of Study</th>
    <th style='border: solid 1px black;'>Location</th>

</tr>
<?php $count = mysqli_num_rows($search_result);

    while($row = mysqli_fetch_array($search_result)):?>
    <tr>
        <td align="center" style='border: solid 1px black;'><?php echo $row['stud_ID'];?></td>
        <td align="center" style='border: solid 1px black;'><?php echo $row['stud_FIELDOFSTUDY'];?></td>
        <td align="center" style='border: solid 1px black;'><?php echo $row['stud_location'];?></td>


    </tr>
<?php endwhile;?>
</table>
<table style='border: solid 1px black;'>
<tr style='border: solid 1px black;'>

    <th style='border: solid 1px black;'>Location Of Employer</th>

</tr>
<?php $count = mysqli_num_rows($search_result);
while($row = mysqli_fetch_array($search_result2)):?>
    <tr>

        <td align="center" style='border: solid 1px black;'><?php echo $row['emp_location'];?></td>

    </tr>
<?php endwhile;?>

    </table>
    <?php echo ("$count") ." ". ("Students");?>
</div>
<div>
<form action="allocation.php" method="post">
<p style="margin-left: 600px; height: 30px; width: 400px;">
<input type="submit" value="Gereate Allocation"/>
</p>
</form>
</div>
研究领域
位置
雇主所在地

和数据库:

<?php

    if (isset($_REQUEST['submit'])){
        $query = "SELECT * FROM student";
        $search_result =filterTable($query);


    }
    else {
        $query = "SELECT * FROM `student`";
        $search_result =filterTable($query);


    }
    if (isset($_REQUEST['submit2'])){
        $query2 = "SELECT * FROM employer";
        $search_result2 =filterTable($query2);


    }
    else {
        $query2 = "SELECT * FROM `employer`";
        $search_result2 =filterTable($query2);


    }

    function filterTable($query)
    {
        $connect=mysqli_connect('127.0.0.1', 'root', 'root',"web");
        $filter_Result = mysqli_query($connect,$query);
        return $filter_Result;
    }
    function filterTable2($query2)
    {
        $connect=mysqli_connect('127.0.0.1', 'root', 'root',"web");
        $filter_Result2 = mysqli_query($connect,$query2);
        return $filter_Result2;
    }
?>


您在找什么?另外,您不应该为每个查询创建mysql连接,我想这是非常低效的。。匹配两个不同表的位置(两个表上类似),然后将特定id分配给学生。关于mysql连接。是的,我会纠正这些。谢谢你在找什么?另外,您不应该为每个查询创建mysql连接,我想这是非常低效的。。匹配两个不同表的位置(两个表上类似),然后将特定id分配给学生。关于mysql连接。是的,我会纠正这些。谢谢