Hello,
By using one of my scripts, i can delete as well as update the fields.I'm using this one using two submit buttons, Update and delete.
Update is very simple: The user make some changes and click update and is updated.
Delete is done in two steps:At the end of each record, there is a check box placed and when the user checks this box and hit delete, it asks for confirmation.
This is also fine!!
Now, instead of two submit buttons, i want to use only one, i.e submit.
How can i modify my piece of code??
Could somebody pls help me out.
Thanks in advance!
<?php
// Delete (btn_delete)
if (isset($HTTP_POST_VARS["btn_delete"]))
{
$delete = $HTTP_POST_VARS["delete"];
if (is_array($delete) && !empty($delete))
{
reset($delete);
while (list($key,$id) = each($delete))
{
$sql = "UPDATE TBL_RBS SET RBS_DELETE = 1
where RBS_ID = $id";
$result = ibase_query($sql);
}
$delete_serialized = urlencode(serialize($delete));
echo "
<center>
<B>Chosen records marked for removal!</B><BR>\n
<B>Do you really want to remove them? </B><BR>\n
<form name=\"formConfirm\" method=\"post\" action=\"\">
<input type=\"hidden\" name=\"delete\" value=\"$delete_serialized\">
<input type=\"submit\" name=\"btn_del_confirmed\" value=\"Delete!\">
<input type=\"submit\" name=\"btn_del_cancel\" value=\"Restore!\"><BR>\n
</form>
</center>
";
exit;
}
}
// Delete confirmed (btn_del_confirmed)
else if (isset($HTTP_POST_VARS["btn_del_confirmed"]))
{
$update = $HTTP_POST_VARS["update"];
$delete = unserialize(urldecode($delete));
reset($delete);
if (is_array($delete) && !empty($delete))
{
reset($delete);
while (list($key,$id) = each($delete))
{
$sql = "DELETE from TBL_RBS where RBS_ID = $id";
$result = ibase_query($sql);
}
}
}
// Delete cancelled (btn_del_cancel)
else if (isset($HTTP_POST_VARS["btn_del_cancel"]))
{
$delete = $HTTP_POST_VARS["delete"];
$delete = unserialize(urldecode($delete));
reset($delete);
if (is_array($delete) && !empty($delete))
{
reset($delete);
while (list($key,$id) = each($delete))
{
$sql = "update TBL_RBS SET RBS_DELETE = 0 where RBS_ID = $id";
$result = ibase_query($sql);
}
}
}
// Update (btn_update)
else if (isset($HTTP_POST_VARS["btn_update"]))
{
reset($data);
while (list($id, $rbs_data) = each($data))
{
//sql update Statement
}
}
//sql select statement
?>
Field headings are here
<?php
//While statement to fetch the records
?>
All form fields are placed here!!
<?php
}
?>
</table>
<Input type="submit" name="btn_update" value="Update">
<input type="submit" name="btn_delete" value="Delete">
</form>
</body>
</html>