Jump to content

moerkel

New Members
  • Posts

    1
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

moerkel's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Hi, I know my topic is very specific but maybe some can help me with my problem. Take a look at the script below. In time all details will be saved as per formular and I need a little adjustment. The details of „type“ and „type2“ should be compared with another table in mySQL. Let´s call the table „type_table“. „type_table“ contains 2 columns called „type“ and „type2“. The entry of my formular should be compared with the datas in „type_table“ and if they match (both details in the same row) all datas exept „type2“ from my formular should be saved in the table „markers“. If the datas of the formular does not compare with „type_table“ there should be a message below the map called „type incorrect“ or „type does not match to type2“ if „type“ is in the table "type_table" but „type2“ is different in the same row. I hope I explained my problem allmost understandable... Can someone help me with this? phpsqlinfo_add.html <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <!-- Copyright 2008 Google Inc. Licensed under the Apache License, Version 2.0: http://www.apache.org/licenses/LICENSE-2.0 --> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8"/> <title>>Title</title> <script src="http://maps.google.com/maps?file=api&v=2&key=XXXXXXXXXXXXXXXXXXXXXXXXXX" type="text/javascript"></script> <script type="text/javascript"> var marker; function initialize() { if (GBrowserIsCompatible()) { var map = new GMap2(document.getElementById("map_canvas")); map.addControl(new GLargeMapControl()); map.addControl(new GMapTypeControl()); map.setCenter(new GLatLng(30.000000, 0.000000), 1); 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>Date:</td> <td><input type='text' id='date'/></td> </tr>" + "<tr><td>9-digit Number:</td> <td><input type='text' id='type'/></td> </tr>" + "<tr><td>3-digit Number:</td> <td><input type='text' id='type2'/></td> </tr>" + "<tr><td></td><td><input type='button' value='Save & Close' onclick='saveData()'/></td></tr>"; marker.openInfoWindow(html); }); map.addOverlay(marker); } }); } } function saveData() { var name = escape(document.getElementById("name").value); var date = escape(document.getElementById("date").value); var type = escape(document.getElementById("type").value); var type2 = escape(document.getElementById("type2").value); var latlng = marker.getLatLng(); var lat = latlng.lat(); var lng = latlng.lng(); var url = "phpsqlinfo_addrow.php?name=" + name + "&date=" + date + "&type=" + type + "&type2=" + type2 + "&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: 600px; height: 400px"></div> <div id="message"></div> </body> </html> phpsqlinfo_addrow.php <?php require("phpsqlinfo_dbinfo.php"); // Gets data from URL parameters $name = $_GET['name']; $date = $_GET['date']; $lat = $_GET['lat']; $lng = $_GET['lng']; $type = $_GET['type']; $type2 = $_GET['type2']; // 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 markers " . " (id, name, date, lat, lng, type, type2 ) " . " VALUES (NULL, '%s', '%s', '%s', '%s', '%s', '%s');", mysql_real_escape_string($name), mysql_real_escape_string($date), mysql_real_escape_string($lat), mysql_real_escape_string($lng), mysql_real_escape_string($type), mysql_real_escape_string($type2)); $result = mysql_query($query); if (!$result) { die('Invalid query: ' . mysql_error()); } ?>
×
×
  • 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.