0

I have a website on which I can add new guests to a db. This list is then displayed on the site. I do have a delete button which deletes the relevant record. I am able to reference to a different page to update the details, however, I would like to create a pop-up instead. In the case with a pop-up, there is no href. I cannot seem to get this to run and still reference the relevant 'id'. Please help

while($row = mysqli_fetch_array($result)){ 
    echo "<tr>";
    echo "<td>" . $row['Name'] . "</td>";
    echo "<td>" . $row['Surname'] . "</td>";
    echo "<td>" . $row['Contact_Number'] . "</td>";
    echo "<td>" . $row['Email'] . "</td>";
    echo "<td>" . $row['Invite_Code'] . "</td>";
    echo "<td>" . "<a onclick='openForm1()' href='?aciton=edit&id" . $row['id'] . "'>Edit</a>". "</td>";
    echo"<td>" . "<a href='deleteData.php?action=delete&id=" . $row['id'] . "'>Delete</a>" . "</td>";
Ghanshyam Nakiya
  • 1,602
  • 17
  • 24
  • If your openForm() returns false or cancels the event the href won't be followed; there isn't a problem having an onclick and an href, just make sure you write your script depending on what you want to happen after the scripting is done. See https://stackoverflow.com/questions/128923/whats-the-effect-of-adding-return-false-to-a-click-event-listener – Caius Jard Jun 14 '19 at 06:17
  • Thanks, that works. However, I still need to click on the link twice for the pop-up to appear. – Lizandre Prinsloo Jun 14 '19 at 06:23
  • That sounds like a script error, unless it's the browser blocking pop ups until the user has interacted with the page in some way – Caius Jard Jun 14 '19 at 12:43

1 Answers1

0

Simply put, unless you do a page load like you are currently using to delete the only way to interact with a database is to use an AJAX call. In general you would use AJAX to delete the record and then some Javascript/jQuery to hide the row.

There is a little more to it, you have to worry about security too, meaning check a cookie or session.

I am not sure how much JS you know but you can Google.