Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Make PHP echo <a href= link> [closed]

Tags:

html

php

mysql

I'm trying to make a value that is retrieved using $row hyperlinked to another page, but I can't figure out why it isn't working.

The area specifically is;

<td><?php echo $row["ID"]; ?></td>

Here is what I am using;

<td>
<?php 
 echo <a href='edit-dispatch-report.php?id=" . $row['ID'] . "' >" . $row['ID'] . "</a>; 
?>
</td>

How come that doesn't work?

like image 435
user3213283 Avatar asked Feb 10 '26 18:02

user3213283


1 Answers

<?php echo <a

You need to pass a string to echo. You can't just start writing HTML in the middle of PHP.

That said, it is generally easier to minimise the amount of HTML in PHP in HTML that you can.

<td>
    <a href='edit-dispatch-report.php?id=<?php echo $row['ID']; ?>'>
        <?php echo $row['ID']; ?>
    </a>
</td>
like image 69
Quentin Avatar answered Feb 12 '26 07:02

Quentin



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!