Hey everyone, I have a question. I created a page that pop-ups when a user clicks a link and that page displays a table of the information that it pulls from the database that I have created.
I want to be able to have a user click an update button next to the entry, so I created a button to appear next to each entry on each row so that they can choose to update that one user if they need to. I am also going to implement a delete button that will ask for confirmation if they want to delete that user.
At the very end of the page, I am going to add an add user button so that you can create a new entry into the database table if a new user is created. I can create buttons for each entry and have a button for the add user and have those buttons that will go to a new page, but I want it to be more real-time so that you don't have to refresh or go to a new page. Does anyone have an idea about what I would need to do? I'll show you what I have for now.
<?php
include_once("sqlConnect.php");
$sql = "SELECT * FROM engineers ORDER BY LastName";
$result = mysqli_query($conn, $sql);
echo "<table style='width:85%'>";
echo "<tr>";
echo "<td>FirstName</td>";
echo "<td>LastName</td>";
echo "<td>Extension</td>";
echo "<td>Office</td>";
echo "<td>Mobile</td>";
echo "<td>Email</td>";
echo "<td>PersonalPhone</td>";
echo "<td>TelephoneAgent</td>";
echo "<td>UserID</td>";
echo "<td>EmployeeID</td>";
while($row = mysqli_fetch_assoc($result))
{
echo "<tr>";
echo "<td>". $row["FirstName"] . "</td>";
echo "<td>". $row["LastName"] . "</td>";
echo "<td>". $row["Extension"] . "</td>";
echo "<td>". $row["Telephone"] . "</td>";
echo "<td>". $row["Mobile"] . "</td>";
echo "<td>". $row["Email"] . "</td>";
echo "<td>". $row["PersonalPhone"] . "</td>";
echo "<td>". $row["TelephoneAgent"] . "</td>";
echo "<td>". $row["UserID"] . "</td>";
echo "<td>". $row["EmployeeID"] . "</td>";
echo "<td><button type='button' id='button'>Update</button></td>";
echo "</tr>";
}
echo "</table>";
?>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.2/jquery.min.js"> </script>
<script>
$(document).ready(function()
{
$('#button').on('click', function()
{
$('#button').hide();
});
});
</script>
</head>
</html>
I did a test to see if I can make the update buttons hide as a start to see if I can get familiar with using jQuery, but I'm only able to make the first update button disappear when I click it and the others remain even after I click them. So I don't know how I can do an individual update for each person if I can't make all the buttons work. Any guidelines or tips would be very helpful. Thank you!