Jump to content

[SOLVED] Need Help Adding Map (Phoogle?)!


ryanfc

Recommended Posts

Ok I have a database of business for the town I live in.  When a user goes selects a category on my site such as Dining, it takes the user to a page where everyone business under that category is listed.  If the business is a paying advertiser the user clicks on their name and it takes them to a page with more detailed information about that business.  One thing I want to add to this page is a map of the location.  There is only one page client_detail.php that pulls the information and displays it so I need the map to pull the address, city, state, zip etc from the database to populate the map showing where the business is located.  I found phoogle, but I am having a hard time finding what code to add to my page so that its brings up the map with that location.  Does anyone know of a site that walks someone still new to php and how to do this?

 

I think I understand part of how phoogle works.  If I am reading it correctly it says that I will only need to add a couple of lines to the php page I want the map on and the phoggle.php takes care of the rest.

 

I think this is the code I am suppose to add to the page:

<?php /**
* Showing valid points table/list with Phoogle Maps
* class developed by Justin Johnson <justinjohnson@system7designs.com>
*/

require_once 'phoogle.php';

$map = new PhoogleMap();
$map->setAPIKey("ABQIAAAA0ksKqHM3yT_xmOPe0DANGRRMlCWGe88WcLmN582t1mFB9gpW6hTvRlzTS-LCJ8nFoD2AGi5vq0X-Yg");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
  <? $map->printGoogleJS(); ?>
   </head>
  <body>
  <?

  $map->addAddress('208 Dingler Ave, Mooresville, NC 28115');
  $map->addAddress('210 Doster Ave, Mooresville, NC 28115');
  $map->addAddress('300 Dingler Ave, Mooresville, NC 28115');
  $map->showMap();

  ?>
  <h3>The following points are displayed on the map:</h3>
  <h4>(displayed using a table with an id of "my_table")</h4>
  <? $map->showValidPoints("table","my_table"); ?>
  <h4>(dispayed using an unordered list with an id of "my_list")</h4>
  <? $map->showValidPoints("list","my_list"); ?>
    </body>

</html>

 

But I don't know how to change that so it brings the address and other information from the database and not hard code it.

 

  $map->addAddress('208 Dingler Ave, Mooresville, NC 28115');

  $map->addAddress('210 Doster Ave, Mooresville, NC 28115');

  $map->addAddress('300 Dingler Ave, Mooresville, NC 28115');

  $map->showMap();

 

 

So can anyone help me with how this is suppose to work?

 

Link to comment
Share on other sites

Google has an javascript function that you can use for maps on your site (a nice 100x100 map of it) all you need to do is supply the query string for it.  I don't know the url off hand, but an alternative choice is using fopen(www.google.com/maps/?location=mylocation) and then extracting the root map data to your page. 

Link to comment
Share on other sites

Guess I am going to be picky, sorry.  I do not want the user to have to click on another tab to see the map.  I want it to load next the the other information.  Just like if you use Yellowbook.com to look up a business.  A map loads next to the business showing where it is.

Link to comment
Share on other sites

Well google maps is what I am trying to use basically.  Phoogle uses the google maps and the api but is suppose to help with using php with it.  What I need to figure out is how to take the code I listed above and supply it with the address and other information it needs from a database and not hard code it.  As every business is loaded into the client_detail.php.  Does that make sense.

 

Here is the link to Phoogle:

http://www.systemsevendesigns.com/phoogle

 

 

I have the code listed in my page but it has the addresses hard coded.  How do I change it to pull the information it needs from the database.

 

Here is the code of my page:

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>myevvspace.com | premium local listings</title>

<link href="myevvspace_style.css" rel="stylesheet" type="text/css" />
<script src="navigation.js" type="text/javascript" language="javascript"></script>

<?php
//db connect lines taken out

require_once 'phoogle.php';
$map = new PhoogleMap();
$map->setAPIKey("ABQIAAAA_xQ_dEBiJhTWuUYd_GnQCxRhPeVs-Y5MVG7J1BB2XI6iFoNTnBT7lQQVb07RhoCpKomWQg7UmVesPw");

$category_num = (int)$_GET['category'];
$sub_category_num = (int)$_GET['sub_category'];

// Collects data from "friends" table
$data = mysql_query("SELECT * FROM client WHERE category = '$category_num' AND sub_category = '$sub_category_num' order by name")
or die(mysql_error());

$filtertext = mysql_query("SELECT title FROM category WHERE id = '$category_num'")
or die(mysql_error());

$categorycrumb = mysql_query("SELECT title FROM category WHERE id = '$category_num'")
or die(mysql_error());

$subcategorycrumb = mysql_query("SELECT * FROM sub_category WHERE id = '$sub_category_num'")
or die(mysql_error());

$sub_list = mysql_query("SELECT * FROM sub_category WHERE category = '$category_num' order by title")
or die(mysql_error());

$location = mysql_query("SELECT title FROM category WHERE id = '$category_num'")
or die(mysql_error());

mysql_close ($conn);
?>
<? $map->printGoogleJS(); ?>
</head>

<body>
<div id="header"><?php include("includes/header.php"); ?></div>
<div id="navigation"><?php include("includes/navigation.php"); ?></div>
<div id="banner"><?php include("includes/ads/banner.php"); ?></div>
<div id="leftcontent">


<p><form class="filter" method="GET" action="client_filter.php"><?php

$cat1 = "Select a Cuisine:<br />";
$cat2 = "Select a Bar Type:<br />";
$cat3 = "Select your Entertainment:<br />";
$cat4 = "Select an Art:<br />";
$cat5 = "Select a Lodging:<br />";
$cat6 = "Select a Community:<br />";
$cat7 = "Select a Real Estate:<br />";
$cat8 = "Select a Service:<br />";

$current_category = $category_num;

if ($current_category == 1) {
echo $cat1;
}
elseif ($current_category == 2) {
echo $cat2;
}
elseif ($current_category == 3) {
echo $cat3;
}
elseif ($current_category == 4) {
echo $cat4;
}
elseif ($current_category == 5) {
echo $cat5;
}
elseif ($current_category == 6) {
echo $cat6;
}
elseif ($current_category == 7) {
echo $cat7;
}
elseif ($current_category ==  {
echo $cat8;
}

echo "<select class=\"filter\" name=subcat>\n"; 
while($sub = mysql_fetch_array( $sub_list ))
{
  echo "<option name=\"sub_category\" value=\"".$sub['id']."\">".$sub['title']."</option>\n";
}
echo "</select><input type=hidden name=category value=
$category_num />\n<br /><div align=\"right\"><input class=\"filter\" type=\"submit\" name=\"Search\" value=\"Search\" /></div>"; ?></form></p></div>
<div id="centercontent">
<div id="breadcrumb" align="right"><?php
Print "<a href=index.php class=breadcrumb>Home</a> :: ";
while ($crumb1 = mysql_fetch_array( $categorycrumb))
{
echo "<a href=client_list.php?category=$category_num class=breadcrumb>{$crumb1['title']}</a> :: ";
}
while ($crumb2 = mysql_fetch_array( $subcategorycrumb))
{
echo "{$crumb2['title']}";
} // end while
?>
</div><p><img src="images/welcome.gif" alt="Welcome" width="106" height="21" /></p>
  <p><?php
while($info = mysql_fetch_array( $data )) {
echo $info['name'], '<br />Address: ', $info['address'], '<br />Phone: ', $info['phone'], '<br /><img src=', $info['logo'], ' alt=United Bank /><br /><br />';
}
$map->addAddress('208 Dingler Ave, Mooresville, NC 28115');
  $map->addAddress('210 Doster Ave, Mooresville, NC 28115');
  $map->addAddress('300 Dingler Ave, Mooresville, NC 28115');
  $map->showMap();
?>
  <h3>The following points are displayed on the map:</h3>
  <h4>(displayed using a table with an id of "my_table")</h4>
  <? $map->showValidPoints("table","my_table"); ?>
  <h4>(dispayed using an unordered list with an id of "my_list")</h4>
  <? $map->showValidPoints("list","my_list"); ?></p>
</div>

<div id="searchbox" align="center"><form method="POST" action="search.php"><img src="images/spacer.gif" width="10" height="8" /><br /><input type="text" id="keyword" name="keyword" value="search" class="search" /></form></div>
<div id="rightcontent" align="center"><p>text</p></div>
</body>
</html>

Link to comment
Share on other sites

Finally figured it out (after messing with it and trying different combinations):

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>myevvspace.com | premium local listings</title>

<link href="myevvspace_style.css" rel="stylesheet" type="text/css" />
<script src="navigation.js" type="text/javascript" language="javascript"></script>

<?php
//database connection take out

require_once 'phoogle.php';
$map = new PhoogleMap();
$map->setAPIKey("ABQIAAAA_xQ_dEBiJhTWuUYd_GnQCxRhPeVs-Y5MVG7J1BB2XI6iFoNTnBT7lQQVb07RhoCpKomWQg7UmVesPw");

$category_num = (int)$_GET['category'];
$sub_category_num = (int)$_GET['sub_category'];

// Collects data from "friends" table
$data = mysql_query("SELECT * FROM client WHERE category = '$category_num' AND sub_category = '$sub_category_num' order by name")
or die(mysql_error());

$filtertext = mysql_query("SELECT title FROM category WHERE id = '$category_num'")
or die(mysql_error());

$categorycrumb = mysql_query("SELECT title FROM category WHERE id = '$category_num'")
or die(mysql_error());

$subcategorycrumb = mysql_query("SELECT * FROM sub_category WHERE id = '$sub_category_num'")
or die(mysql_error());

$sub_list = mysql_query("SELECT * FROM sub_category WHERE category = '$category_num' order by title")
or die(mysql_error());

$location = mysql_query("SELECT title FROM category WHERE id = '$category_num'")
or die(mysql_error());

mysql_close ($conn);
?>
<? $map->printGoogleJS(); ?>
</head>

<body>
<div id="header"><?php include("includes/header.php"); ?></div>
<div id="navigation"><?php include("includes/navigation.php"); ?></div>
<div id="banner"><?php include("includes/ads/banner.php"); ?></div>
<div id="leftcontent">


<p><form class="filter" method="GET" action="client_filter.php"><?php

$cat1 = "Select a Cuisine:<br />";
$cat2 = "Select a Bar Type:<br />";
$cat3 = "Select your Entertainment:<br />";
$cat4 = "Select an Art:<br />";
$cat5 = "Select a Lodging:<br />";
$cat6 = "Select a Community:<br />";
$cat7 = "Select a Real Estate:<br />";
$cat8 = "Select a Service:<br />";

$current_category = $category_num;

if ($current_category == 1) {
echo $cat1;
}
elseif ($current_category == 2) {
echo $cat2;
}
elseif ($current_category == 3) {
echo $cat3;
}
elseif ($current_category == 4) {
echo $cat4;
}
elseif ($current_category == 5) {
echo $cat5;
}
elseif ($current_category == 6) {
echo $cat6;
}
elseif ($current_category == 7) {
echo $cat7;
}
elseif ($current_category ==  {
echo $cat8;
}

echo "<select class=\"filter\" name=subcat>\n"; 
while($sub = mysql_fetch_array( $sub_list ))
{
  echo "<option name=\"sub_category\" value=\"".$sub['id']."\">".$sub['title']."</option>\n";
}
echo "</select><input type=hidden name=category value=
$category_num />\n<br /><div align=\"right\"><input class=\"filter\" type=\"submit\" name=\"Search\" value=\"Search\" /></div>"; ?></form></p></div>
<div id="centercontent">
<div id="breadcrumb" align="right"><?php
Print "<a href=index.php class=breadcrumb>Home</a> :: ";
while ($crumb1 = mysql_fetch_array( $categorycrumb))
{
echo "<a href=client_list.php?category=$category_num class=breadcrumb>{$crumb1['title']}</a> :: ";
}
while ($crumb2 = mysql_fetch_array( $subcategorycrumb))
{
echo "{$crumb2['title']}";
} // end while
?>
</div><p><img src="images/welcome.gif" alt="Welcome" width="106" height="21" /></p>
  <p><?php
while($info = mysql_fetch_array( $data )) {
echo $info['name'], '<br />Address: ', $info['address'], '<br />Phone: ', $info['phone'], '<br /><img src=', $info['logo'], ' alt=United Bank /><br /><br />';
$map->addAddress("{$info['address']}, {$info['city']}, {$info['state']} {$info['zip']}");
$map->showMap();
}
?></p>
<h3>The following points are displayed on the map:</h3>
  <h4>(displayed using a table with an id of "my_table")</h4>
  <? $map->showValidPoints("table","my_table"); ?>
  <h4>(dispayed using an unordered list with an id of "my_list")</h4>
  <? $map->showValidPoints("list","my_list"); ?>
</div>

<div id="searchbox" align="center"><form method="POST" action="search.php"><img src="images/spacer.gif" width="10" height="8" /><br /><input type="text" id="keyword" name="keyword" value="search" class="search" /></form></div>
<div id="rightcontent" align="center"><p>text</p></div>
</body>
</html>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.