简体   繁体   中英

Give href to a php variable

I want to give href link to the variable below;

echo "<td>" . $row['userid'] . "</td>";

So that admin can click on that ID and in the other page admin can see all details about the user, using this id.

I tried;

    echo "<td><a href="http://www.google.com">" . $row['userid'] . "</a></td>";

and

    echo "<td>"<a href="http://www.google.com"> . $row['userid'] . </a>"</td>";

But they didn't work. Thanks in advance.

edit: Thanks to @Gautam the answer I'm looking for is below;

echo "<td><a href='http://www.google.com'>". $row['expiry'] . "</a></td>";

use this

echo "<td><a href='http://www.google.com/'". $row['expiry'] .">Click Here</a></td>";

or else

?>
<td><a href="http://www.google.com/<?php echo $row['expiry'] ?>">Click Here</a></td>

You are gettting error because of quotes. Change the quotes for href to single quotes like below and should work fine.

 echo "<td><a href='http://www.google.com'>". $row['expiry'] . "</a></td>";

Please use single quotas for your link. If you are using double quotas you will close your echo instead of opening quotas within other quotas:

echo "<td><a href='http://www.google.com'>" . $row['expiry'] . "</a></td>";

Otherwise you also could use \\ in order to escape the double quotas:

echo "<td><a href=\"http://www.google.com\">" . $row['expiry'] . "</a></td>";

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM