I need to update & delete data in the same page.
My problem is how to get the update or delete record id in the same page while the user clicks the "update" or "delete" link.
Anyone please help how to update and delete records in same page.
Please find my code below (View.php)
View.php
<?php
$q =($_GET['q']);
if($q=="all")
{
$result=mysql_query("select * from password");
}
else
{
$result=mysql_query("select * from password WHERE tag = '".$q."'");
}
if($result === false )
{
die(mysql_error());
}
?>
<table>
<thead>
<tr>
<th>Id</th>
<th>Name</th>
<th>username</th>
<th>Password</th>
<th>Account Type</th>
<th>Link</th>
<th>update</th>
<th>Delete</th>
</tr>
</thead>
<?php
while($row=mysql_fetch_array($result))
{
$id=$row['id'];
$name=$row['name'];
$url=$row['url'];
$uname=$row['username'];
$pass=$row['password'];
$tag=$row['tag'];
$des=$row['description'];
?>
<tbody>
<tr>
<td><?php echo $id; ?></td>
<td><?php echo $name; ?></td>
<td><?php echo $uname; ?></td>
<td><span data-tooltip aria-haspopup="true" class="has-tip" title="<?php echo $pass; ?>">View</span></td>
<td><?php echo $des; ?></td>
<td><a href="<?php echo $url; ?>" title="<?php echo $name; ?>" target="_blank">Link</a></td>
<td><a href="update.php?<?php echo $id; ?>">Update</a></td>
<td><a href="delete.php?<?php echo $id; ?>">Delete</a></td>
</tr>
</tbody>
<?php
}
?>
</table>