echo a url in a new window
Moderator: General Moderators
echo a url in a new window
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.
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.
Re: echo a url in a new window
What line is the parser error on........
- 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
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.
Re: echo a url in a new window
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.
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.
Re: echo a url in a new window
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?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>';
- 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
You've done something wrong then. What's the view source of the browser for that line?mendenha wrote: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?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>';
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.
- 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
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.
Re: echo a url in a new window
This code works perfect!! Thank you very much for helping me.AbraCadaver wrote:Never mind, I see ASCII 34 is ".
Code: Select all
echo '<br /><a href="' . $row['menu'] . '" target="_blank">Menu</a>';