Jump to content

Add Hyperlinks To Data Pulled From Mysql Via Php


webguync

Recommended Posts

I am trying to make a few HTML fields into hyperlinks that are pulling data from MySQL into PHP. My syntax is currently off, so I need some assistance. I have tried this.

 


<td><a href="mailto:<?php echo $record['email_t'];?></a></td>
<td><a href="<?php echo $record['url_t'];?></a></td>

 

I am basically just trying to make the email a mailto link and the url field a hyperlink.

 

Any help is greatly appreciated!

Link to comment
Share on other sites


<td><a href="mailto:<?php echo $record['email_t'];?></a></td>
<td><a href="<?php echo $record['url_t'];?></a></td>

 

Look at the HTML source that is being produced and the problems would be clearly evident. The output would look something like this:

<td><a href="mailto:value_of_email_t</a></td>
<td><a href="value_of_url_t</a></td>

 

You are opening the href parameter using a quote mark and then adding the dynamic value. But, you never 1) close the href parameter with a quote, 2) close the opening A tag or 3) provide a value to be between the opening/closing A tags (i.e. text to be the actual hyper-link. If you want the same value to be the href location AND the displayed hyperlink, this should work (assuming the values are valid for this purpose)

<td><a href="mailto:<?php echo $record['email_t'];?>"><?php echo $record['email_t'];?></a></td>
<td><a href="<?php echo $record['url_t'];?>"><?php echo $record['url_t'];?></a></td>

 

Or my preference

echo "<td><a href='mailto:{$record['email_t']}'>{$record['email_t']}</a></td>\n";
echo "<td><a href='{$record['url_t']}'>{$record['url_t']}</a></td>\n";

Edited by Psycho
Link to comment
Share on other sites

This is probably easy, but I am a little rusty. How would I turn these rows of data into clickable links. Not sure how where to add the <a href="linkURL"></a> part.

 


<td><?php echo $record['email_t'];?></td>
<td><?php echo $record['url_t'];?></td>

 

Thanks in advance!

Link to comment
Share on other sites

Are you seriously confused about how to do that? What are you stuck on? And how is this different from the last time you asked and were given the answer?

 

http://forums.phpfreaks.com/topic/269484-turning-field-display-into-hyperlinks/

 

I seriously don't understand how you can do MySQL queries, write enough PHP to process the data from those queries (which you've done in other posts), yet you are confused about how to echo text and make a hyperlink, when you've already been given the answer?

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.