You are here: Problem appending values to an object « PHP « IT news, forums, messages
Problem appending values to an object

Posted by David Pollack on 08/22/05 20:04

I have a database with two tables. One is a table of events and the
other is a table of locations. I'm creating a google map with the
table of locations and would like to list the events at each place.
I'm using mambo and the following query to get the data...

$query2 = "SELECT #__places.*, #__events.title"
. "\n FROM #__places, #__events"
. "\n WHERE #__places.name = #__events.adresse_info"
. "\n AND published='1'"
. "\n ORDER BY ordering"
;

$database->setQuery( $query2 );
$rows = $database->loadObjectList();

This returns the variable $rows with all the data I need to plot the
points on the map and the titles of the events going on at each of
these places. $rows is an array containing objects of each row of
data. The problem I'm having is that some places have multiple events
and when I plot the points, it'll plot multiple points for those
places.

What I'd like to do is collapse the array $rows so that when the name
of a place is duplicated only the title of the event is added and not
all the other duplicate info. I feel like this may be possible either
through manipulation of the data in PHP or by using another sql query.
Any help would be greatly appreciated.

Here's some extra info in case you need it:

// The call used to map all the points
<?
$j = 0;
foreach ($rows as $row) {
?>

var html = createHTML("<? echo "$row->name"; ?>", "<? echo
"$row->address"; ?>", "<? echo "$row->suburb"; ?>", "<? echo
"$row->state"; ?>", "<? echo "$row->postcode"; ?>");
var point = new GPoint(<? echo "$row->lng"; ?>,<? echo "$row->lat"; ?>);
var marker = createMarker(point, html);
map.addOverlay(marker);
<?
if($sname == $row->name) {
?>
marker.openInfoWindowHtml(html);

<?
}
}
?>

And here's the URL of the site

http://www.atlspecials.com/index.php?option=com_places&task=view&Itemid=17


--
David Pollack
DHPollack@gmail.com

 

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

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