phpsqlinfo_add.html

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

    <meta http-equiv="content-type" content="text/html; charset=utf-8"/
>

    <title>Google Maps JavaScript API Example: Simple Map</title>
    <script src="http://maps.google.com/maps?
file=api&v=2.x&key=ABQIAAAA4LQHj8_8pDEumt0ZD_-
bmxRLlSC1PrCBC6gZBDTi4m30FLGlNBR8GJrM2xZFHpj1mVPQP3WVfyJrQg"
            type="text/javascript"></script>
    <script type="text/javascript">

    var marker;

    function initialize() {
      if (GBrowserIsCompatible()) {
        var map = new GMap2(document.getElementById("map_canvas"));
        map.setCenter(new GLatLng(40.157808,-83.008257), 13);

        GEvent.addListener(map, "click", function(overlay, latlng) {
          if (latlng) {
            marker = new GMarker(latlng, {draggable:true});
            GEvent.addListener(marker, "click", function() {
              var html = "<table>" +
                         "<tr><td>Name:</td> <td><input type='text'
id='name'/> </td> </tr>" +
                         "<tr><td>Address:</td> <td><input type='text'
id='address'/></td> </tr>" +
                         "<tr><td>Type:</td> <td><select id='type'>" +
                         "<option value='Pothole' SELECTED>Pothole</
option>" +
                         "<option value='Office'>Office</option>" +
                         "</select> </td></tr>" +
                         "<tr><td></td><td><input type='button'
value='Save' onclick='saveData()'/></td></tr>";

              marker.openInfoWindow(html);
            });
            map.addOverlay(marker);
          }
        });

      }
    }

    function saveData() {
      var name = escape(document.getElementById("name").value);
      var address = escape(document.getElementById("address").value);
      var type = document.getElementById("type").value;
      var latlng = marker.getLatLng();
      var lat = latlng.lat();
      var lng = latlng.lng();

      var url = "phpsqlinfo_addrow.php?name=" + name + "&address=" +
address +
                "&type=" + type + "&lat=" + lat + "&lng=" + lng;
      GDownloadUrl(url, function(data, responseCode) {
        if (responseCode == 200 && data.length <= 1) {
          marker.closeInfoWindow();
          document.getElementById("message").innerHTML = "Location
added.";
        }
      });
    }
    </script>

  </head>

  <body onload="initialize()" onunload="GUnload()">
    <div id="map_canvas" style="width: 500px; height: 300px"></div>
    <div id="message"></div>
  </body>

</html>

phpsqlinfo_dbinfo.php
--------------------------------
<?
$username="root";
$password="";
$database="marker_db";
?>
phpsqlinfo_addrow.php
---------------------------------
<?php
require("phpsqlinfo_dbinfo.php");

// Gets data from URL parameters
$name = $_GET['name'];
$address = $_GET['address'];
$lat = $_GET['lat'];
$lng = $_GET['lng'];
$type = $_GET['type'];

// Opens a connection to a MySQL server
$connection=mysql_connect ("localhost", $username, $password);
if (!$connection) {
  die('Not connected : ' . mysql_error());
}

// Set the active MySQL database
$db_selected = mysql_select_db($database, $connection);
if (!$db_selected) {
  die ('Can\'t use db : ' . mysql_error());
}

// Insert new row with user data
$query = sprintf("INSERT INTO markers1 " .
         " (id, name, address, lat, lng, type ) " .
         " VALUES (NULL, '%s', '%s', '%s', '%s', '%s');",
         mysql_real_escape_string($name),
         mysql_real_escape_string($address),
         mysql_real_escape_string($lat),
         mysql_real_escape_string($lng),
         mysql_real_escape_string($type));

$result = mysql_query($query);

if (!$result) {
  die('Invalid query: ' . mysql_error());
}

?>
------------------------
These are the files I used ...and I created the markers table as per
the article above and also created the database name marker_db...Would
you please help me regarding this problem..or Do you have any other
solution for this application..?

Thank you very much the reply...



On Mar 10, 4:09 pm, Rossko <[email protected]> wrote:
> > Yeah ,I tried the way that mention in that article but when I click
> > the save button it is not doing anything
>
> On your own there, unless you share a bit more with us.  Have you got
> a database set up and waiting?  Have you a php script ready to be fed
> results?   If you give a url to your webpage we can use debuggers to
> see if that part works as expected.

-- 
You received this message because you are subscribed to the Google Groups 
"Google Maps API" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-maps-api?hl=en.

Reply via email to