how do you make a hyperlink in php?

Ye' old general discussion board. Basically, for everything that isn't covered elsewhere. Come here to shoot the breeze, shoot your mouth off, or whatever suits your fancy.
This forum is not for asking programming related questions.

Moderator: General Moderators

Post Reply
PHPNEWBIE123
Forum Newbie
Posts: 1
Joined: Fri Nov 05, 2010 11:17 pm

how do you make a hyperlink in php?

Post by PHPNEWBIE123 »

Ok so here's what iam doing. I have a premade site template that is made of mysql and php. Iam trying to edit it. In the backend of the site i can upload data. so iam uploading a domain name. The domain name is showing up on the site from the database. But how can i make it an active hyperlink? Remember the link would change evrytime for every different page depending on what i uploaded to the database
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: how do you make a hyperlink in php?

Post by Christopher »

Usually displaying database values looks something like this:

Code: Select all

<?php
// using double quotes
echo "<a href=\"{$row['url']}\">{$row['name']}</a>";
// using single quotes
echo '<a href="' . $row['url']. '">' . $row['name'] . '</a>';
?>
<!-- or you can embed PHP tags in HTML -->
<a href="<?php echo $row['url']; ?>"><php echo $row['name']; ?></a>
(#10850)
Post Reply