Problem appending values to an object

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxx

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux