Jump to content

open href in new blank window


teknospr

Recommended Posts

Hello:

 

I wrote the following script. It is working fine, I just need the links to open in a blank window. Any help will be appreciated.

 

<html>

<body>

<?php

  $connection = mysql_connect("localhost",

        "username",

        "password");

 

    mysql_select_db("articles", $connection);

$query="SELECT * FROM articles WHERE id=1";

$result=mysql_query($query);

 

$num=mysql_numrows($result);

 

mysql_close();

?>

<table border="1" cellspacing="2" cellpadding="2">

<tr>

<th><font face="Arial, Helvetica, sans-serif">Article</font></th>

<th><font face="Arial, Helvetica, sans-serif">Year</font></th>

<th><font face="Arial, Helvetica, sans-serif">Description</font></th>

<th><font face="Arial, Helvetica, sans-serif">Location</font></th>

 

</tr>

 

<?php

$i=0;

while ($i < $num) {

 

$f1=mysql_result($result,$i,"article");

$f2=mysql_result($result,$i,"year");

$f3=mysql_result($result,$i,"description");

$f4=mysql_result($result,$i,"location");

$f5=mysql_result($result,$i,"link")

?>

 

<tr>

<td><font face="Arial, Helvetica, sans-serif"><?php echo $f1; ?></font></td>

<td><font face="Arial, Helvetica, sans-serif"><?php echo $f2; ?></font></td>

<td><font face="Arial, Helvetica, sans-serif"><?php echo $f3; ?></font></td>

<td><font face="Arial, Helvetica, sans-serif"><?php echo  "<a href=".$f5.">".$f4."</a>"; ?></font></td>

</tr>

<tr>

</tr>

 

<?php

$i++;

}

?>

</body>

</html>

Link to comment
Share on other sites

Please read the rules : all code is to be posted within the forums [

]...[

] tags.

 

answer to your question - just include

target="_blank"

at the end of the html for the anchor (just after the href="") however, your problem will be that you arn't concatenating your strings properly.  Have a go at this:

<td><font face="Arial, Helvetica, sans-serif"><?php echo  "<a href=\"$f5\" target=\"_blank\">$f4</a>"; ?></font></td>

should get it

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.