Jump to content

Need To Make Sql Query Into Hyperlink That Opens New Window


klotzdr

Recommended Posts

I have a SQL query that pulls information from a coins DB, the title is converted into a hyperlink, the link works, but I need it to open in a new browser window.

 

Here is the PHP code:

 

<?php

$dbc = mysql_connect('homesaleacrescom.ipagemysql.com', 'xxxxxxx', 'xxxxx');

if (!$dbc) {

die('Could not connect: ' . mysql_error());

}

 

mysql_select_db('coins', $dbc);

 

$query = ("SELECT * FROM listings" );

 

$result = mysql_query($query);

 

echo "<table width='100%' border='0'>

<tr>

</tr>";

 

while($row = mysql_fetch_array($result)){

$link=$rows["url"];

 

echo "<tr>";

echo "<td>" ."<a href='". $row['url'] ."' >". $row['title'] . "</a>". "</td>";

echo "<td>" . $row['price'] . "</td>";

echo "</tr>";

}

echo "</table>";

 

if (!mysql_query($query,$dbc))

{

die('Error: ' . mysql_error());

}

 

mysql_close($dbc);

?>

 

Right now i have all the links set up just to point to yahoo.com as this is just test data, but need to links to open up a new browser window.

 

Here is the actual address to the site to see what I am talking about:

 

http://silverhalves.com/indextest.php

Link to comment
Share on other sites

Regarding new windows, and the difference between target="_blank" and target="_new": http://www.searchenginejournal.com/when-not-to-use-target_blank-link-attribute/19924/

 

You might want to consider a modal box instead of actually opening a new browser window. A lot of people really hate having new windows open unless they specifically want it to happen that way.

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.