You are here: Re: Opening links from a table « PHP Programming Language « IT news, forums, messages
Re: Opening links from a table

Posted by Toby A Inkster on 06/18/07 11:08

phill.luckhurst@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/

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация