Jump to content

Displaying links as text on site


creatives

Recommended Posts

Hi guys,

 

I am slowly learning about php and mysql.

 

I am inputting my database via phpmyadmin.

 

However, I am struggling on something I just can't seem to find an answer on, and thats displaying url data on a webpage, using php, but as text links, for eg "Joe bloggs runs down the road" that is clickable and opens in a new window.

 

Do I have to imput the URL in a separate field from the description within a database table, and display them as text links via customised php code, or is there a way of setting this up in phpmyadmin or mysql so that one field displays as a text link?

 

Any suggestions?

 

Your help would be really appreciates as I am totally stuck :-\

 

Many thanks!

Link to comment
Share on other sites

If you're talking about including HTML in a field, this has nothing to do with either php or mysql... just dump out the contents as-is (assuming you're not messing around with entities and such).  Otherwise, if you want to link the entire record to something, you'll need another field.  And no, phpmyadmin doesn't know anything about either of these.

Link to comment
Share on other sites

Thanks for the reply.

 

Hmm ok, so how would you recommend I make a simple links site, with links shown as descriptions by using a mysql database.

 

Sorry if I am posting in the wrong section, but I am really stuck as to what to do next.

 

Basically, my site will be numerous webpages, each webpage will be for an individual person, and I would like to display links that relate to that person on their webpage, but shown as description.

 

I know how to set up a mysql database via my hosting provider, and I know how to populate it via phpmyadmin.  I could always set up a php script to populate the database instead if you feel this is a better method.

 

Its just this displaying of links as decriptions that driving me crazy, lol :'(

 

Thanks for your help!

Link to comment
Share on other sites

You could store the link in one table say A  ( http://www.yoursite.com )

Put the link text in another table, say B  ( some text for the link )

 

then in your page populate the links from your database.

 

$sql = "SELECT * FROM database";
      mysql_query($sql)
      $result = mysql_query($sql);
$row = mysql_fetch_assoc($result);

echo "<a href='{$row['A']}'>{$row['B']}</a>";

 

I havent tested this, but that should give you a link that reads  some text for the link and links to www.yoursite.com

Link to comment
Share on other sites

Thanks for that! very helpful:)

 

Can I not put the url link in a separate field within the same table as the description text?  Just wondering why it has to be in a separate table?

 

Thanks!

 

The above code does exactly that.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.