Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

While Loop taking ID value for a href

while loop:

   <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>

when I press the a href for each record it always results in this url
http://localhost/helloworld/read.php?id=%27.%20$row%5B%27id%27%5D%20.%27

I think its the syntax of the —- > href="read.php?id='. $row['id'] .'" but I’ve tried all the variations that I can find as a php beginner, it’s driving me nuts!

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

PHP shorthand tag for echo is missing in href link.

This Code snippet should work:

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

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading