1

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>';
1
  • Is the database storing just the "www.sonsofanrchy.tv"? If so, try adding switching it to <a href="htt:///\'' . $row... Commented Nov 9, 2013 at 0:27

2 Answers 2

1
echo '<td> <a href="http://'.$row['url'].'" target="_blank" style="color: #137e80">' . $row['url'] . '</a></td>';
Sign up to request clarification or add additional context in comments.

3 Comments

This was helpful and it nearly works, it seems to leave out the : after http.
Nearly? If $row['url'] returns URL like this: www.example.com not http://www.example.com then it have to work.
ah i see. The link i was testing with had http:// in the database entry. I removed it and your code worked as you said it would! I will have to change my application so it removes the "http://" when someone submits a link. Thanks for your help!
1

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.