Page 1 of 1

echo a url in a new window

Posted: Tue Jan 12, 2010 2:39 pm
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.

Re: echo a url in a new window

Posted: Tue Jan 12, 2010 3:14 pm
by JNettles
What line is the parser error on........

Re: echo a url in a new window

Posted: Tue Jan 12, 2010 3:21 pm
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>';

Re: echo a url in a new window

Posted: Tue Jan 12, 2010 3:23 pm
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.

Re: echo a url in a new window

Posted: Tue Jan 12, 2010 3:44 pm
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?

Re: echo a url in a new window

Posted: Tue Jan 12, 2010 3:45 pm
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?

Re: echo a url in a new window

Posted: Tue Jan 12, 2010 3:47 pm
by AbraCadaver
Never mind, I see ASCII 34 is ".

Code: Select all

echo '<br /><a href="' . $row['menu'] . '" target="_blank">Menu</a>';

Re: echo a url in a new window

Posted: Tue Jan 12, 2010 4:10 pm
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.