Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

Sending ID of a PHP row with HTML button

  • 30-03-2015 05:28PM
    #1
    Registered Users, Registered Users 2 Posts: 2,609 ✭✭✭


    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