Jump to content

Clickable links


brianc

Recommended Posts

I'm pulling data from data base. It is website address (outside of main website). But when it is diplayed on the page. The hyperlink shows My web site and then the website pulled from data base.

 

example: http://www.searchobits.com/www.keplingerfuneralhome.com

 

I just want it to show www.keplingerfuneralhome.com HOW CAN I FIX THIS?

 

<tr>

<td></td>

<td><a class=ls href=<?=$a1[Website]?>>Website</a></td>

</tr>

Link to comment
https://forums.phpfreaks.com/topic/185598-clickable-links/
Share on other sites

is every instance the same?  will it always look like this: http://www.searchobits.com/www.keplingerfuneralhome.com?

 

<?php
$str = str_replace ('http://www.searchobits.com/', '', $row['url']);
?>

 

i'm sure it's not since that information is usually pried from the OP, but assuming it is, something very simple like what i have above would suffice.

Link to comment
https://forums.phpfreaks.com/topic/185598-clickable-links/#findComment-979872
Share on other sites

That is why he posted a reference to the manual for parse_url

 

If you were to click on that link they show an example of usage:

 

Examples

 

Example #1 A parse_url() example

<?php

$url = 'http://username:password@hostname/path?arg=value#anchor';

 

print_r(parse_url($url));

 

echo parse_url($url, PHP_URL_PATH);

?>

 

The above example will output:

 

Array

(

    [scheme] => http

    [host] => hostname

    [user] => username

    [pass] => password

    [path] => /path

    [query] => arg=value

    [fragment] => anchor

)

/path

 

Perhaps reading that / reading through the user comments on that manual page will help you figure it out.

 

You can use that to see if http is in the url, if it is not you add it. Alternatively you can use a stristr to locate if the http:// is in the url (which this can be tricked if there is a query parameter with http://), so I would suggest using the parse_url method.

Link to comment
https://forums.phpfreaks.com/topic/185598-clickable-links/#findComment-979897
Share on other sites

It is pulled from a data base that people have posted.

 

This would be much simpler if you were to post your code. Content does not magically get displayed on a web page just becuase you pulled records from a database. There must be some code that actually "prepares" the HTML code for the links. For example, does the value in the database include the entire link, i.e. everything from the opening A tag to the closing A tag? Or, does the value in the DB only include the URL and you are building the HTML anchor? The answer to that will require different solutions.

Link to comment
https://forums.phpfreaks.com/topic/185598-clickable-links/#findComment-980260
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.