Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Sending ID of a PHP row with HTML button

Options
  • 30-03-2015 5:28pm
    #1
    Registered Users Posts: 2,589 ✭✭✭


    I have a site that uses google maps API to add markers to a map and also add details for these markers and save them to a PHP database. These saved markers then can be clicked and they bring up an info window displaying thee specific data for that marker.

    The PHP/HTML that displays the info window is:
    $result = mysqli_query($con, "SELECT * FROM events");

    while($row = mysqli_fetch_array($result))
    {
    echo "<div class='event-details' id='event-details' style='display: none ''>";
    echo "<h3>Event Details</h3>";
    echo "<table class='table'>";
    echo "<tr><th>Event Name: </th><td>" . $row . "</td></tr>";
    echo "<tr><th>Event Date: </th><td>" . $row . "</td></tr>";
    echo "<tr><th>Event Type: </th><td>" . $row . "</td></tr>";
    echo "<tr><th>Event Details: </th><td>" . $row . "</td></tr>";
    echo"</table>";
    echo "<td><a href='details.php?id=".$row."' class='btn btn-warning btn-sm'>View</a></td></div>";
    }


    The JS that displays this info with each marker is:
    var eventList = $("#event-details").clone().show();

    // Display Event details on marker click
    google.maps.event.addListener(event_markers, "click", function () {
    infowindow.setContent(eventList[0]);
    infowindow.open(map, event_markers);
    map.setCenter(marker.getPosition());
    map.setZoom(10);
    });

    Each item in the DB has a unique ID. I want to use this ID variable so that I can send it to other pages so the info can be viewed or that row can be deleted from the DB using its ID.

    As of now, there are 3 different items in the 'events' DB, with ID's being, 6, 7, and 8. Now when I inspect element on each of the markers, they all say that
    <a href="details.php?id=6" class="btn btn-warning btn-sm">View</a>

    But I want them to display their own ID, not just the first one. So when I click the marker that has an ID of 8 in the DB, it should say "details.php?id=8", and NOT "details.php?id=6"
    Tagged:


Advertisement