PHP Delete Record with Confirmation Window Support

This is an extension for DreamweaverMX using the built-in PHP_MySQL server model. This behavior inserts a "delete" link for your record which will display a confirmation dialog when clicked. If confirmed, the link passes the record ID to a delete page you specify. This behavior should be used on a page that displays a record or a repeat region displaying a series of records, in conjunction with a separate delete page which contains the standard Macromedia "Delete Record" behavior.

Overview

Current Version: 1.0.1
Compatability: DreamweaverMX
Platform: Windows/MacOSX
Brought to you by: www.brettbrewer.com

Useage:
This behavior assumes you are displaying some kind of record on your page, either a single record, or one within a "repeat region" behavior. It also assumes you are linking to a page containing the standard "delete record" PHP behavior.

To use it, simply place your cursor where you want the "delete" link to appear or highlight some text to replace with the link. Then choose "BRB PHP Behaviors ---> Insert a Delete Link" from the Server Behaviors panel. Enter the specified parameters and your confirmation message and click OK. Presto! You've got a delete link that pops up a confirmation window before passing the record ID to the delete page you specified.

UI Access
Access from Server Behaviors palate by choosing "BRB PHP Behaviors ---> Insert a Delete Link".

What's new:
Minor UI and documentation updates. Added file browser functionality to UI.

Version History:
Verions 1.0.1 - Minor UI and documentation updates. Added branding.
Version 1.0 - Initial release.

To-do:
Suggestions Welcome.

Requirements

Type: Server Behavior
Product: Dreamweaver MX
Server Model: PHP MySQL
Platform: Win XP/2000/2003/2008/7, Mac OS 8.6 or higher
Browser: IE 4, Netscape 4

Reviews

slect and delete

November 14, 2003 by Mustafa Oguz Kalfaoglu
<?php require_once('Connections/cesar.php'); ?>
<?php
$maxRows_goster = 10;
$pageNum_goster = 0;
if (isset($_GET['pageNum_goster'])) {
  $pageNum_goster = $_GET['pageNum_goster'];
}
$startRow_goster = $pageNum_goster * $maxRows_goster;

mysql_select_db($database_cesar, $cesar);
$query_goster = "SELECT * FROM GRUP ORDER BY GROUP_NO ASC";
$query_limit_goster = sprintf("%s LIMIT %d, %d", $query_goster, $startRow_goster, $maxRows_goster);
$goster = mysql_query($query_limit_goster, $cesar) or die(mysql_error());
$row_goster = mysql_fetch_assoc($goster);

if (isset($_GET['totalRows_goster'])) {
  $totalRows_goster = $_GET['totalRows_goster'];
} else {
  $all_goster = mysql_query($query_goster);
  $totalRows_goster = mysql_num_rows($all_goster);
}
$totalPages_goster = ceil($totalRows_goster/$maxRows_goster)-1;
?>
<script language="JavaScript" type="text/JavaScript">
<!--
function BRB_PHP_DelWithCon(deletepage_url,field_name,field_value,messagetext) { //v1.0 - Deletes a record with confirmation
  if (confirm(messagetext)==1){
    location.href = eval('\"'+deletepage_url+'?'+field_name+'='+field_value+'\"');
  }
}
//-->
</script>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset="iso"-8859-9">
</head>

<body>
<table border="1" cellpadding="1" cellspacing="1">
  <tr>
  <td></td>
    <td>GROUP_NO</td>
    <td>GROUP_NAME</td>
    <td>UYE</td>
  </tr>
  <?php do { ?>
  <tr>
  <td><a href="javascript:BRB_PHP_DelWithCon('a.php','GROUP_NO',<?php echo $row_goster['GROUP_NO']; ?>,'Are you sure you want to delete this record?');">delete Record</a>
</td>
    <td><?php echo $row_goster['GROUP_NO']; ?></td>
    <td><?php echo $row_goster['GROUP_NAME']; ?></td>
    <td><?php echo $row_goster['UYE']; ?></td>
  </tr>
  <?php } while ($row_goster = mysql_fetch_assoc($goster)); ?>
</table>
</body>
</html>
<?php
mysql_free_result($goster);
?>

Simple is good, but needs a bit more...

June 23, 2004 by Kevin Farley

I like the simplicity of this script but, if my destination "delete" page is for instance "index.php?mode=del" the script isn't built to recognize an existing variable and just adds another ?.  One other thing, I would love to be able to specify the name of the variable being passed myself instead of just choosing the value from the recordset list. Little too prohibative, but nothing a quick tamper doesn't fix.

K.

You must me logged in to write a review.