簡體   English   中英

While Loop 為 href 獲取 ID 值

[英]While Loop taking ID value for a href

while循環:

   <tbody>
                        <?php while($row=$result->fetch_assoc()){ ?>
                            <tr> 
                                <td><?= $row['id']; ?></td>
                                <td><?= $row['fornavn']; ?></td>
                                <td><?= $row['efternavn']; ?></td>
                                <td><?= $row['mail']; ?></td>
                                <td><?= $row['kursistnummer']; ?></td>
                                <td><?= $row['unilogin']; ?></td>
                                <td>
                                <a href="read.php?id='. $row['id'] .'" class="mr-3" title="View Record" data-toggle="tooltip"><span class="fa fa-eye"></span></a>
                                </td>
                            </tr>
                        <?php } ?>
                    </tbody>

當我為每條記錄按 a href 時,它總是會導致這個 url http://localhost/helloworld/read.php.%20=%27.%2%2[%20=%27]%2

我認為它的語法 ---- > href="read.php?id='. $row['id'].'"但我已經嘗試了作為 php 初學者可以找到的所有變體,它快把我逼瘋了!

回聲的 PHP 速記標記在 href 鏈接中丟失。

此代碼段應該可以工作:

<a href="<?= 'read.php?id='. $row['id'] ?>" class="mr-3" title="View Record" data-toggle="tooltip"><span class="fa fa-eye"></span></a>

使用"" '' id 屬性,因為您在. $row['id']. . $row['id'].

所以像這樣:

href="read.php?id='. $row["id"] .'"

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM