Corey
Corey

Reputation: 327

Using php/mysql to populate href link

I want my hyperlinks destination to be filled by a value from my database. However, when I click the link in my app it doesn't clear the "http://localhost/videoStorageApp/" before inserting the URl value from the database.

QUESTION: How do I clear the web browser url so only the URL value form the database is used?

WHAT I AM GETTING: http://localhost/videoStorageApp/'www.sonsofanarchy.tv'
WHAT I WANT: www.sonsofanarchy.tv

CODE:

This is the line that displays the hyperlink in question, if more code is needed please ask and ill add anything else that's needed:

echo '<td> <a href="\'' . $row['url'] . '\'" target="_blank" style="color: #137e80" (\''.$row['url'].'\');return false;">' . $row['url'] . '</a></td>';

Upvotes: 1

Views: 2297

Answers (2)

frnhr
frnhr

Reputation: 12903

You are probably missing "http://" in your href attribute.

<a href="google.com">

... will take you to http://currentsite.com/maybe-a-subfolder/google.com

<a href="http://google.com">

... will take you to http://google.com

Upvotes: 1

speccode
speccode

Reputation: 1562

echo '<td> <a href="http://'.$row['url'].'" target="_blank" style="color: #137e80">' . $row['url'] . '</a></td>';

Upvotes: 1

Related Questions