Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

PHP - How to echo a url string as a clickable url?

Featured Replies

​I'm currently learning PHP to build search box functionality.

 

echo "Page: ".$rs['sitepage'];

 

At the moment, I can echo 'sitepage' to bring up the string (url) that is written in the sitepage column of a table.

 

How can I make the url clickable, so the user can click on it?

 

Thanks for any help.

  • Author

This seems to work: echo "<a href='".$rs['sitepage']."'>Link</a>";

 

Although, I prefer it to just echo the clickable / whole url straight off the bat, and not bother showing the `Link'.

 

Thanks for any help.

The browser can't convert the URL to a link automatically, you'll have to echo the var in the HREF attribute, and between the <a> tags for it to display the URL and link to it.

<?php
echo "<a href=\"".$rs['sitepage']."\">".$rs['sitepage']."</a>;
?>

Edited by jpeters8889

  • Author

 

The browser can't convert the URL to a link automatically, you'll have to echo the var in the HREF attribute, and between the <a> tags for it to display the URL and link to it.

<?php
echo "<a href=\"".$rs['sitepage']."\">".$rs['sitepage']."</a>;
?>

 

Thank you very much, jpeters8889. I will try to work with that code. When I paste it into my PHP with the other echo statements, (with or without the <?php ?>) I'm getting a bunch of other coding errors (not your code though) for the first time coming up in Dreamweaver, including in the HTML part of the .php page, too. I'm a little out of my depth, but I'll work with your code.

Thank you. I much appreciate this.

 

Edit:

 

echo "<a href=\"".$rs['sitepage']."\">".$rs['sitepage']."</a>";

 

I added " at the end and it works!

 

Thank you very much for your help.

Edited by Grant Barker

  • Author

Thanks NOCK.

That's good to know.

It's a slow process, but it's enjoyable learning PHP.

Cheers.

 

Thank you very much, jpeters8889. I will try to work with that code. When I paste it into my PHP with the other echo statements, (with or without the <?php ?>) I'm getting a bunch of other coding errors (not your code though) for the first time coming up in Dreamweaver, including in the HTML part of the .php page, too. I'm a little out of my depth, but I'll work with your code.

Thank you. I much appreciate this.

 

Edit:

 

echo "<a href=\"".$rs['sitepage']."\">".$rs['sitepage']."</a>";

 

I added " at the end and it works!

 

Thank you very much for your help.

 

My mistake, I wrote it in a rush and forgot the closing " at the end, glad you sorted it though :)

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.