Reply to Re: [PHP] Problem appending values to an object

Your name:

Reply:


Posted by "Richard Lynch" on 08/23/05 09:43

On Mon, August 22, 2005 10:04 am, David Pollack wrote:
> 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.

That may not be a problem, since the multiple points may simply
over-write each other, and you won't know the difference visually...

What I did in one similar situation, not yet finished, was to plot a
BIGGER dot (or whatever) when there were multiple "things" at one
point.

The more things, the bigger the dot.

You could even use ORDER BY (abs(lat) + abs(lng)) to get points "near"
each other to be sequential so that... [continued]

> 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;

$unique = array();

> foreach ($rows as $row) {

if (!isset($unique[$row->lng . '.' $row->lat])){

> ?>
>
> 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);
>
> <?

$unique[$row->lng . '.' . $row->lat] = true;
}

> }
> }
> ?>
>
> And here's the URL of the site

You could also do some basic arithmetic on the lng/lat and "cheat" the
dots over/up a bit if they are "too close" to a previously-used dot.

You may also want to consider trying to get each dot to have a number
($j leaps to mind) or something in the balloon image, so that you can
put corresponding numbers in the image and in the sidebar HTML so the
user can match up the map with the specials.

Otherwise, the connection between mapped points and drink specials is
too tenuous.

[continued]... and if you've used the ORDER BY suggested above, and
the bigger dots, you can have, EG, 5,6 in a balloon instead of just 5,
and then the nearby things will be listed together in an intuitive
way.

--
Like Music?
http://l-i-e.com/artists.htm

[Back to original 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

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