使用javascript在页面上运行PHP代码

使用javascript在页面上运行PHP代码,javascript,php,jquery,html,Javascript,Php,Jquery,Html,我的整个HTML页面都在一个PHP文件中。(index.php) 我的index.php是这样的: some HTML code... Kiválasztott hét: <select id="hetvalaszto" onchange="changeWeek()"> <?php $connection = mysqli_connect("localhost:8889","root","root","imreigye_wp") or die("Error " . my

我的整个HTML页面都在一个PHP文件中。(index.php) 我的index.php是这样的:

some HTML code...
Kiválasztott hét: <select id="hetvalaszto" onchange="changeWeek()">
<?php
    $connection = mysqli_connect("localhost:8889","root","root","imreigye_wp") or die("Error " . mysqli_error($connection));
    mysqli_set_charset($connection, 'utf8mb4');

    $sql = "select * from rendelesiidok order by het";

    $result = mysqli_query($connection, $sql) or die("Error in Selecting " . mysqli_error($connection));
    $prevhet = "";

    $hszarr = array();
    while($row =mysqli_fetch_assoc($result))
    {
        if ($row['Het'] == $prevhet) {} else if ($row['Het'] == "999") 
            echo "<option value=" . $row['Het'] . ">Alap hét</option>";
        else
            echo "<option value=" . $row['Het'] . ">" . $row['Het'] . ". hét</option>";
        $prevhet = $row['Het'];
    }
    mysqli_close($connection);
?>
</select>
...some more HTML code
一些HTML代码。。。
基瓦拉斯托特·赫特:
…更多的HTML代码

PHP代码填充一个下拉列表。我想做的是:我想在页面加载后使用javascript或jquery重新填充下拉列表。为此,我需要再次运行php代码。

U需要在页面加载后使用javascript函数运行的AJAX请求为什么要在javascript中使用此请求?