Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7176879
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T16:35:51+00:00 2026-05-28T16:35:51+00:00

i have a database where each row has lat/long info for goggle maps. each

  • 0

i have a database where each row has lat/long info for goggle maps.
each row subsequently gets turned into a marker. when i click on that marker, an info window pops up.

i want the info window to have a button so that when clicked, the entry from the database will get deleted. but my button won’t work. specifically, something about the eraseEntry() function attached to the onClick event isn’t working. when i click the button, only the last entry of the database gets deleted, regardless of which marker i click.

var map=//make the google map
var markersArray = [];
var infoWindow = new google.maps.InfoWindow({content: ""});
var markers;

$.get("phpsqlajax_genxml.php", function(data) 
{
    markers = data.documentElement.getElementsByTagName("marker");
    makeMarkersWithXMLinfo(); 
});

function makeMarkersWithXMLinfo() 
{
    for (var i = 0; i < markers.length; i++) 
    {
            var name = markers[i].getAttribute("name");
            var markerLocation = new google.maps.LatLng(parseFloat(markers[i].getAttribute("lat")),parseFloat(markers[i].getAttribute("lng")));
            var html = "<b>" + name + "</b> <br/>" + 
                        "</b> <br/>" + "</b> <br/>" +
                        "<input type='button' value='Erase Entry' onclick='eraseEntry()'/>";
            var markerWithLocation = new google.maps.Marker({position: markerLocation, map: map});
            var markerWithInfo = createMarker(markerWithLocation,html);
            eraseEntry = function ()
            {
                    $.get("delete.php", { identifierVar: name } );
            }
    }
}

function createMarker(markerWithLocation, html) {
    var markerWithInfo = google.maps.event.addListener(markerWithLocation, 'click',          function(){infoWindow.setContent(html); infoWindow.open(map,markerWithLocation)});
    return markerWithInfo;
}

i’m able to pull from the database and create the markers just fine.
i’ve tried having the eraseEntry() function call another function that’s outside of the makeMarkersWithXMLinf() function, but i still get the same problem. depending where i put/call those functions, sometimes javascript doesn’t even think my function exists…

below’s my delete.php file

<?php
require("phpsqlajax_dbinfo.php");
// 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());
}

if(isset($_GET['identifierVar']))
{
    $query = 'DELETE FROM markers WHERE name = '.(int)$_GET['identifierVar'];
    $result = mysql_query($query);
}
?>

i’ve been testing with just unique names.
like 111, 222, 333.. etc
any help’s appreciated. thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T16:35:52+00:00Added an answer on May 28, 2026 at 4:35 pm
    1. identifierVar should be identifierId, where identifierId is the id of that marker. try making these delete queries with the id, its much faster and it’s a unique value.
    2. your query is probably like this: delete from x where name = '$name'. you need to limit to 1, like: delete from x where name = '$name' limit 1
    3. after you’ve successfully deleted the marker from database, delete it off the map
    4. use firebug always in your debugging
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In a mysql database I have table of geographical areas where each row has
I have a database where each row has an id, a URL, and an
I have a database with a lot a currencies and each row has a
I have a database of employees and their direct manager. Each employee row has
I have a DBase IV database. Each row has a memo field with a
I have one PHP script inserting rows in a MySQL database. Each row has
I have a database table where each row (movie) has a couple of numeric
I have a million rows in a database table. For each row I have
I have a database populated with 1 million objects. Each object has a 'tags'
I have a simple hierarchy of categories in an SQLite3 database, each row storing

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.