-
Recently Browsing 0 members
- No registered users viewing this page.
-
Similar Content
-
- 0 replies
- 10 views
-
- 3 answers
- 3,875 views
-
QNAP issues patch for an RCE security vulnerability affecting PHP in NAS Drive management
By Alap Naik Desai,
- remote code execution
- rce
- (and 12 more)
- 0 replies
- 10 views
-
Get this Dynamic 2022 Data & IT Security Training Bundle at 97% off
By News Staff,
- neowin deals
- cyber security
- (and 4 more)
- 0 replies
- 10 views
-
- 8 replies
- 2,410 views
-
Question
rajibkd
I am very new to web development and trying to develop a web application. I am kind of stuck at a point. The page let the user insert through a form in mysql database and display the values in a display table on the same page. The display table has edit link for each row , when edit link is clicked then the insert form should display the values based on the id and let the user to edit the values and save the new values in the database.And the display table should be updated to after updating the form.
<div class="main-bod">
<h1>District Entry Form</h1>
<div class="row">
<div class="col-md-6">
<form action="<?php echo($config["url"]["actions"]."district-entry.php") ?>" method="post" class="entry-form">
<label>District ID:</label>
<input type="text" name="id" value="" readonly>
<label>Name of District:</label>
<input type="text" name="name" autofocus required>
<center>
<button type="submit"><i class="fa fa-check"> </i> Save</button>
<button type="reset" name="reset"><i class="fa fa-undo"> </i> Reset</button>
</center>
</form>
</div>
<div class="col-md-6">
<table class="settings-table">
<thead>
<tr>
<th>District ID</th>
<th>Name of District</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<?php
$conn = new mysqli(DB_SERVER, DB_USER, DB_PASS, DB_NAME);
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "SELECT id, name FROM district";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
while($row = $result->fetch_assoc()) {
echo "<tr><td>".$row["id"]."</td><td>".$row["name"]."</td><td><a href=\"".$_SERVER['REQUEST_URI']."/" . $row["id"] . "\"><i class=\"fa fa-edit\"> </i> Edit</a></td></tr>";
}
}
$conn->close();
?>
</tbody>
</table>
</div>
</div>
</div>
<script>
$("input[name=id]").val(parseInt($("tr:last").find("td:first-child").html())+1);
</script>
Link to comment
https://www.neowin.net/forum/topic/1389479-need-help-with-edit-link-in-a-display-table-to-update-on-the-same-page/Share on other sites
0 answers to this question
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now