homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

help opening in new window
php mysql resulted link open in new window when clicked

 5:19 pm on Apr 1, 2009 (gmt 0)
What I am needing is someone to teach me how to open the link that is returned from mysql db in a new separate window.

Here is my code:


mysql_connect("localhost", $dbUser, $dbPassword);
mysql_select_db("contents") or die(mysql_error());

echo "";

$get_links = mysql_query("SELECT * FROM groups ORDER BY group_name");
while ($array = mysql_fetch_array($get_links))

echo "<br><br><a href=\"$array[group_URL]\">$array[group_name]</a> ";
if ($array[group_desc]<>"")
{echo", $array[group_desc]";};


echo "";





 6:57 pm on Apr 1, 2009 (gmt 0)

You need to set the "target" property of your link to "_blank".

<a href="http://www.example.com/" target="_blank">go to example</a>


 7:06 pm on Apr 1, 2009 (gmt 0)

I've tried that and all I get is a blank page. For some reason it doesn't like - maybe beacuse of the
$array[group_URL] is not a direct http://www.example.com/
In mysql db the url is: http://www.example.com/

Any other suggestions to work around?


 8:17 pm on Apr 1, 2009 (gmt 0)

Figured it out - don't know why but it prefers the target before the href code like below:

echo "<br><br><a target=\"_blank\" href=\"$array[group_URL]\">$array[group_name]</a>";

Might have also been the problem of the missing \ after target= also.

Anyway - it works!
thanks jezra for the help.


 8:36 pm on Apr 1, 2009 (gmt 0)

It was the latter. You must have the syntax correct. You could turn up error_reporting [php.net] in your test environment and you will catch these errors. Also don't forget that you can always use the W3 validator on your rendered HTML to make sure you do not have any issues.

Welcome to WebmasterWorld, Tylee.

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved