Jump to content

Recommended Posts

I used search function, could not find a subject that addressed my need.  I hope I am not repeating a well answered question.

 

I have two MySql fields I want to hyperlink, but not as text links, but with an image.

 

Here is truncated code, if more deatail is need, I can post.  Both links work fine now, but show the person's email name and google map link text - looks unproffessional and I think  the email links may be able to be harvested by spammers.

 

The E-mail link:

  echo "<td><a href=mailto:".$row['email'] . ">" .$row['email'] . "</a></td>";

 

The Google map link:

  echo "<td><a target='_blank' href=".$row['location_map_link'] . ">" .$row['location_map_link'] . "</a></td>";

 

Can we use images in this code?

 

I am not a PHP coder!!

 

Ron
 

Link to comment
https://forums.phpfreaks.com/topic/291024-hyperlink-button-based-on-mysql/
Share on other sites

Can we use images in this code?

 

It's difficult to tell what exactly you need to do, but you can use an image as the link. You just need to wrap the <a> tag around an <img> tag. For an example, scroll down to Example 2 here:

https://developer.mozilla.org/en-US/docs/Web/HTML/Element/img

Edited by cyberRobot

What I am having a difficult time with is wrapping my head aroiund how i would reference an image inside the code I referenced here.  My problem is lack of skill in php/mysql.

 

So I want to know if the following links can be editied to be image links, not text.

 

So, the question is, can I use images intead of text in these two pieces of code?  I worked them myself to get text links, but I cannot get images referenced in them, everything I do crashes the code and I get a blank page.

 

The E-mail link:

  echo "<td><a href=mailto:".$row['email'] . ">" .$row['email'] . "</a></td>";  <------- Put an image reference in here instead of text!!

 

The Google map link:

  echo "<td><a target='_blank' href=".$row['location_map_link'] . ">" .$row['location_map_link'] . "</a></td>"; <------- Put an image reference in here instead of text!!

 

Thanks!!

 

Ron

I worked them myself to get text links, but I cannot get images referenced in them, everything I do crashes the code and I get a blank page.

 

Could you post the code that you've tried? Perhaps we can help fix this issue. When posting the code, please surround it with


tags. It will make your post and code easier to follow.  :happy-04:

You can create an anchor on an image, but you cannot put an image as the reference in an anchor.  You could eliminate the mail anchor, and instead handle that server side with PHPMailer.  The reason I suggest this is that even if you change the output, the source will always have the email address, and the source is what is scraped.

  • Like 1
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.