echo a url in a new window

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
mendenha
Forum Newbie
Posts: 19
Joined: Tue Jan 12, 2010 2:24 pm

echo a url in a new window

Post by mendenha »

I've been trying to figure this out for the past few days but I can't seem to get it working. First off here is the section of code I'm working with:

echo "<td class='contact'><b>" . $row['name'] . "</b>";
echo "<br />" . $row['category'];
echo "<br />" . $row['address'];
echo "<br />" . $row['phone'];
echo "<br /><a href=" . chr(34) . $row['menu'] . chr(34) . ">Menu</a>";
echo "<br /><a href=" . chr(34) . $row['map'] . chr(34) . ">Map</a>";
/*echo "<br /><a href=" . chr(34) . $row['review'] . chr(34) . ">Reviews</a>";*/
echo "<br /><a href=" . chr(34) . $row['website'] . chr(34) . ">Website</a></td>";
echo "</tr>";

When a user click on Menu, Map or Website I would like it to open in a new window.

I've added in target="_blank" in different areas and it hasn't worked yet. I always get a parse syntax error.

Any help would be greatly appreciated.
User avatar
JNettles
Forum Contributor
Posts: 228
Joined: Mon Oct 05, 2009 4:09 pm

Re: echo a url in a new window

Post by JNettles »

What line is the parser error on........
User avatar
AbraCadaver
DevNet Master
Posts: 2572
Joined: Mon Feb 24, 2003 10:12 am
Location: The Republic of Texas
Contact:

Re: echo a url in a new window

Post by AbraCadaver »

You need to study this: http://us.php.net/manual/en/language.types.string.php

Code: Select all

echo '<br /><a href="' . chr(34) . $row['menu'] . chr(34) . '" target="_blank">Menu</a>';
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
mendenha
Forum Newbie
Posts: 19
Joined: Tue Jan 12, 2010 2:24 pm

Re: echo a url in a new window

Post by mendenha »

As of right now it doesn't happen on any line. It's when I add in the target=_"blank" is when that happens.

echo "<td class='contact'><b>" . $row['name'] . "</b>";
echo "<br />" . $row['category'];
echo "<br />" . $row['address'];
echo "<br />" . $row['phone'];
echo "<br /><a href=" . chr(34) . $row['menu'] . chr(34) . ">Menu</a>";
echo "<br /><a href=" . chr(34) . $row['map'] . chr(34) . ">Map</a>";
/*echo "<br /><a href=" . chr(34) . $row['review'] . chr(34) . ">Reviews</a>";*/
echo "<br /><a href=" . chr(34) . $row['website'] . chr(34) . target=_"blank" ">Website</a></td>";
echo "</tr>";

With the code above I added in the target=_"blank" on the last line so that'll be the line I'll get the error on.
mendenha
Forum Newbie
Posts: 19
Joined: Tue Jan 12, 2010 2:24 pm

Re: echo a url in a new window

Post by mendenha »

AbraCadaver wrote:You need to study this: http://us.php.net/manual/en/language.types.string.php

Code: Select all

echo '<br /><a href="' . chr(34) . $row['menu'] . chr(34) . '" target="_blank">Menu</a>';
This works to open a new page but the page that it opens is blank. It's almost like it's not passing the header info?
User avatar
AbraCadaver
DevNet Master
Posts: 2572
Joined: Mon Feb 24, 2003 10:12 am
Location: The Republic of Texas
Contact:

Re: echo a url in a new window

Post by AbraCadaver »

mendenha wrote:
AbraCadaver wrote:You need to study this: http://us.php.net/manual/en/language.types.string.php

Code: Select all

echo '<br /><a href="' . chr(34) . $row['menu'] . chr(34) . '" target="_blank">Menu</a>';
This works to open a new page but the page that it opens is blank. It's almost like it's not passing the header info?
You've done something wrong then. What's the view source of the browser for that line?
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
User avatar
AbraCadaver
DevNet Master
Posts: 2572
Joined: Mon Feb 24, 2003 10:12 am
Location: The Republic of Texas
Contact:

Re: echo a url in a new window

Post by AbraCadaver »

Never mind, I see ASCII 34 is ".

Code: Select all

echo '<br /><a href="' . $row['menu'] . '" target="_blank">Menu</a>';
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
mendenha
Forum Newbie
Posts: 19
Joined: Tue Jan 12, 2010 2:24 pm

Re: echo a url in a new window

Post by mendenha »

AbraCadaver wrote:Never mind, I see ASCII 34 is ".

Code: Select all

echo '<br /><a href="' . $row['menu'] . '" target="_blank">Menu</a>';
This code works perfect!! Thank you very much for helping me.
Post Reply