0

I have a MySQL database in my php page that is a repeating field. The raw data being entered into the database is: <a href="http://www.link.com/">Link</a>

The code in my page works fine, but when I click on it in the browser, I need it to open in a _blank window. I know it's probably simple, but I cant find the answer anywhere.

My code on the page is: <?php echo $row_rsManufacturers['manufacturer']; ?>

How do I change it to open in a blank window?

Thanks

user2930069
  • 49
  • 1
  • 3
  • Possible duplicate of [How can I open a link in new tab (and not new window)?](http://stackoverflow.com/questions/6296013/how-can-i-open-a-link-in-new-tab-and-not-new-window) – Andy Hoffner Jan 20 '16 at 17:55

2 Answers2

0

In order to open a link in a new window you must add the target attribute.

<a href="http://www.link.com/" target="_blank"> Link</a>

Modify the links in the database to use the target attribute.

  • Thanks, but I was hoping to not have to add the target to every entry I put in the database. I remember somewhere, there was php code I could wrap around my code to have it open in a blank window, but I just don't recall where I had it. – user2930069 Jan 20 '16 at 17:47
0

I found it.

I changed my database to have only the www address and wrapped my code around the following and it works.

<?php 
if($row_rsDatabaseTable['databasefield'] != "") { ?>
    <a href="http://<?php echo $row_rsDatabaseTable['databasefield']; ?>" target="_blank"><?php echo $row_rsDatabaseTable['databasefield']; ?></a>

Thanks!

user2930069
  • 49
  • 1
  • 3