Hyperlink?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Vinnar
Forum Commoner
Posts: 32
Joined: Tue Feb 01, 2011 11:00 am

Hyperlink?

Post by Vinnar »

Hey guys

Just a quick question:

How to embed hyperlink into a database cell?

Basically I echo out a table on the user interface of my site

and there's an URL in one of the cells

I want the user to access it by clicking on it, without copying and pasting the URL into the URL bar of the browser

I tried updating the cell in phpmyadmin using <a href = http://www.example.com>http://www.example.com</a> but didn't work out, the resulting cell only had the text format

Any help would be appreciated

Thanks.
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Re: Hyperlink?

Post by califdon »

First, do yourself a favor and learn the way databases work. There is no such thing as a "cell" in a database. That's more than just terminology, it is fundamental to thinking about databases instead of spreadsheets, which do have cells.

Second, your problem has nothing at all to do with the database. When you use the data from the database to build your HTML, that's where you create a hyperlink, because the "anchor" syntax (<a href=...) is part of HTML, not part of the data.

So you should have PHP code which does something like this:

Code: Select all

echo "<td><a href='" . $row['link'] . "'>" . $row['link'] . "</a></td>";
Post Reply