无论如何,我可以循环组合php和html

时间:2019-05-29 12:08:00

标签: php loops mysqli

我正在尝试循环html和php的组合。唯一需要更改的是将mysqli_data_seek($result, 0);从0更改为1到2等。将其存储在变量中。我只是想知道是否有可能。

我试图将整个代码放入while函数中。但是我觉得我不会像这样去任何地方。

此代码需要循环。并且更改应该发生在mysqli_data_seek($result, 0);

<div class="stellingen">
    <div class="stelling-wrapper" id="btn1">
        <img src="images/button.svg" alt="Show more..." class="btn" id="bton">
        <p type="button" class="stelling">
            <?php
            if ($result = mysqli_query($con, "SELECT * FROM stellingen WHERE REGIOID=1;")) {
                mysqli_data_seek($result, 0);
                $row = mysqli_fetch_assoc($result);
                $stellingid = $row["Stelling_ID"];
                echo "<p>{$row["Stelling"]}</p>";
            }
            ?>

    </div>
    <div id="p1">
        <table id="tabel" border=1px class="data">
            <tr>
                <th>Title</th>
                <th>Source</th>
                <th>Weight</th>
                <th>Date</th>
            </tr>

            <?php
            $sql1 = "SELECT * FROM stelling WHERE stelling_iD=$stellingid;";
            $records1 = mysqli_query($con, $sql1);
            $recordscheck = mysqli_num_rows($records1);

            if ($recordscheck > 0) {
                while ($stelling = mysqli_fetch_assoc($records1)) {
                    echo "<tr>";
                    echo "<td>" . $stelling['Title'] . "</td>";
                    echo "<td>" . $stelling['Source'] . "</td>";
                    echo "<td>" . $stelling['Wheight'] . "</td>";
                    echo "<td>" . $stelling['Timer'] . "</td>";
                    echo "</tr>";
                }
            }
            ?>
        </table>
    </div>


</div>
</div>
</div>

我希望代码能够循环显示,就像我将其复制粘贴到它下面并更改一个值一样。

0 个答案:

没有答案