468,290 Members | 1,849 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,290 developers. It's quick & easy.

Opening links from a table

I'm using the following code to display som items from a database.

field_2 shows a link that is clickable. I would like to make it
clickable but open the link in a new page (in a _blank way) instead of
onto itself but I'm not sure how to do it.

{
echo "var point = new GLatLng(" . $row['field_5'] . "," .
$row['field_4'] . ");\n";
echo "var marker = createMarker(point, '" .
addslashes($row['field_1']) . "<br /><a href=\"" . $row['field_2'] . "
\">". $row['field_2'] ."</a><br .>" . $row['field_3'] . "',3);\n";
echo "map.addOverlay(marker);\n";
echo "\n";
}

Jun 18 '07 #1
6 1234
why not:
{
echo "var point = new GLatLng(" . $row['field_5'] . "," .
$row['field_4'] . ");\n";
echo "var marker = createMarker(point, '" .
addslashes($row['field_1']) . "<br /><a href=\"" . $row['field_2'] . "
\" target='_blank'>". $row['field_2'] ."</a><br .>" . $row['field_3'] . "',3);\n";
echo "map.addOverlay(marker);\n";
echo "\n";

}
Jun 18 '07 #2
In our last episode,
<11**********************@u2g2000hsc.googlegroups. com>,
the lovely and talented ph*************@googlemail.com
broadcast on comp.lang.php:
I'm using the following code to display som items from a database.
field_2 shows a link that is clickable. I would like to make it
clickable but open the link in a new page (in a _blank way) instead of
onto itself but I'm not sure how to do it.
How exactly is this a PHP problem and not a Javascript problem?

--
Lars Eighner <http://larseighner.com/ <http://myspace.com/larseighner>
Countdown: 582 days to go.
An amazing thing about Christians: people who doubt being related to monkeys,
but are certain they belong to the same species as Paris Hilton or Karl Rove.
Jun 18 '07 #3
On 18 Jun, 08:30, Lammi <Lorenz.Lammersd...@gmail.comwrote:
why not:
{
echo "var point = new GLatLng(" . $row['field_5'] . "," .
$row['field_4'] . ");\n";
echo "var marker = createMarker(point, '" .
addslashes($row['field_1']) . "<br /><a href=\"" . $row['field_2'] . "
\" target='_blank'>". $row['field_2'] ."</a><br .>" . $row['field_3'] . "',3);\n";
echo "map.addOverlay(marker);\n";
echo "\n";
}- Hide quoted text -

- Show quoted text -
Beacuse I'm useless

Jun 18 '07 #4
On 18 Jun, 08:30, Lammi <Lorenz.Lammersd...@gmail.comwrote:
why not:
{
echo "var point = new GLatLng(" . $row['field_5'] . "," .
$row['field_4'] . ");\n";
echo "var marker = createMarker(point, '" .
addslashes($row['field_1']) . "<br /><a href=\"" . $row['field_2'] . "
\" target='_blank'>". $row['field_2'] ."</a><br .>" . $row['field_3'] . "',3);\n";
echo "map.addOverlay(marker);\n";
echo "\n";
}- Hide quoted text -

- Show quoted text -
Because I'n useless and still cannot work it out. I'm now going to
hide in a corner and cry.

Jun 18 '07 #5
ph*************@googlemail.com wrote:
echo "var point = new GLatLng(" . $row['field_5'] . "," .
$row['field_4'] . ");\n";
echo "var marker = createMarker(point, '" .
addslashes($row['field_1']) . "<br /><a href=\"" . $row['field_2'] . "
\">". $row['field_2'] ."</a><br .>" . $row['field_3'] . "',3);\n";
echo "map.addOverlay(marker);\n";
echo "\n";
This kind of mess can be avoided by liberal use of printf.

printf("var point = new GLatLng(%f, %f);\n"
."var marker = createMarker(point, '%s<br /><a href=\"%s\">%s</a><br />%s', 3);\n"
."map.addOverlay(marker);\n\n"
, $row['field_5']
, $row['field_4']
, addslashes(htmlentities($row['field_1']))
, addslashes(htmlentities($row['field_2']))
, addslashes(htmlentities($row['field_2']))
, addslashes(htmlentities($row['field_3']))
);

Or better still:

$markertext = sprintf('%s<br /><a href="%s">%s</a><br />%s'
, htmlentities($row['field_1'])
, htmlentities($row['field_2'])
, htmlentities($row['field_2'])
, htmlentities($row['field_3'])
);
printf("var point = new GLatLng(%f, %f);\n"
."var marker = createMarker(point, '%s', 3);\n"
."map.addOverlay(marker);\n\n"
, $row['field_5']
, $row['field_4']
, addslashes($markertext)
);

This makes it clear where to add your target="_blank":

$markertext = sprintf('%s<br /><a href="%s" target="_blank">%s</a><br />%s'
, htmlentities($row['field_1'])
, htmlentities($row['field_2'])
, htmlentities($row['field_2'])
, htmlentities($row['field_3'])
);
printf("var point = new GLatLng(%f, %f);\n"
."var marker = createMarker(point, '%s', 3);\n"
."map.addOverlay(marker);\n\n"
, $row['field_5']
, $row['field_4']
, addslashes($markertext)
);

Though I'd avoid creating a popup like this -- it breaks the "back"
button and confuses users.

--
Toby A Inkster BSc (Hons) ARCS
[Geek of HTML/SQL/Perl/PHP/Python/Apache/Linux]
[OS: Linux 2.6.12-12mdksmp, up 114 days, 18:42.]

You're Not Allowed to Take Pictures of the US Embassy in Rome
http://tobyinkster.co.uk/blog/2007/06/16/us-embassy/
Jun 18 '07 #6
On 18 Jun, 12:08, Toby A Inkster <usenet200...@tobyinkster.co.uk>
wrote:
phill.luckhu...@googlemail.com wrote:
echo "var point = new GLatLng(" . $row['field_5'] . "," .
$row['field_4'] . ");\n";
echo "var marker = createMarker(point, '" .
addslashes($row['field_1']) . "<br /><a href=\"" . $row['field_2'] . "
\">". $row['field_2'] ."</a><br .>" . $row['field_3'] . "',3);\n";
echo "map.addOverlay(marker);\n";
echo "\n";

This kind of mess can be avoided by liberal use of printf.

printf("var point = new GLatLng(%f, %f);\n"
."var marker = createMarker(point, '%s<br /><a href=\"%s\">%s</a><br />%s', 3);\n"
."map.addOverlay(marker);\n\n"
, $row['field_5']
, $row['field_4']
, addslashes(htmlentities($row['field_1']))
, addslashes(htmlentities($row['field_2']))
, addslashes(htmlentities($row['field_2']))
, addslashes(htmlentities($row['field_3']))
);

Or better still:

$markertext = sprintf('%s<br /><a href="%s">%s</a><br />%s'
, htmlentities($row['field_1'])
, htmlentities($row['field_2'])
, htmlentities($row['field_2'])
, htmlentities($row['field_3'])
);
printf("var point = new GLatLng(%f, %f);\n"
."var marker = createMarker(point, '%s', 3);\n"
."map.addOverlay(marker);\n\n"
, $row['field_5']
, $row['field_4']
, addslashes($markertext)
);

This makes it clear where to add your target="_blank":

$markertext = sprintf('%s<br /><a href="%s" target="_blank">%s</a><br />%s'
, htmlentities($row['field_1'])
, htmlentities($row['field_2'])
, htmlentities($row['field_2'])
, htmlentities($row['field_3'])
);
printf("var point = new GLatLng(%f, %f);\n"
."var marker = createMarker(point, '%s', 3);\n"
."map.addOverlay(marker);\n\n"
, $row['field_5']
, $row['field_4']
, addslashes($markertext)
);

Though I'd avoid creating a popup like this -- it breaks the "back"
button and confuses users.

--
Toby A Inkster BSc (Hons) ARCS
[Geek of HTML/SQL/Perl/PHP/Python/Apache/Linux]
[OS: Linux 2.6.12-12mdksmp, up 114 days, 18:42.]

You're Not Allowed to Take Pictures of the US Embassy in Rome
http://tobyinkster.co.uk/blog/2007/06/16/us-embassy/
Thank you Toby.

This is my first fray into coding so am greatful for your help. It's
quite a learning curve.

Jun 18 '07 #7

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

14 posts views Thread by D. Alvarado | last post: by
4 posts views Thread by Niranjan | last post: by
44 posts views Thread by Viken Karaguesian | last post: by
reply views Thread by dew | last post: by
5 posts views Thread by k.vanderstarren | last post: by
3 posts views Thread by nimajneb via AccessMonster.com | last post: by
reply views Thread by NPC403 | last post: by
2 posts views Thread by MrBee | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.