Reply
Eric - code for the page below. I run WinXP on a P4. DWCS4 and DA2.0.6.
Hope you can come up with something - look forward to hearing from you.
Regards
Gary
<?php require_once('../Connections/connCompats.php'); ?>
<?php require_once("../WA_DataAssist/WA_AppBuilder_PHP.php"); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
?>
<?php
$ParamcartID_WADAcartridges = "-1";
if (isset($_GET['cartID'])) {
$ParamcartID_WADAcartridges = (get_magic_quotes_gpc()) ? $_GET['cartID'] : addslashes($_GET['cartID']);
}
mysql_select_db($database_connCompats, $connCompats);
$query_WADAcartridges = sprintf("SELECT cartID, compatsRef, cartCode, cartDescr, cartColor, cartImage FROM cartridges WHERE cartID = %s", GetSQLValueString($ParamcartID_WADAcartridges, "int"));
$WADAcartridges = mysql_query($query_WADAcartridges, $connCompats) or die(mysql_error());
$row_WADAcartridges = mysql_fetch_assoc($WADAcartridges);
$totalRows_WADAcartridges = mysql_num_rows($WADAcartridges);
$targetCart_rsCart2Printer = "1";
if (isset($_GET['cartID'])) {
$targetCart_rsCart2Printer = (get_magic_quotes_gpc()) ? $_GET['cartID'] : addslashes($_GET['cartID']);
}
mysql_select_db($database_connCompats, $connCompats);
$query_rsCart2Printer = sprintf("SELECT carts2printers.cart2PrinterID, carts2printers.cartID, carts2printers.printerID, printers.printerName FROM carts2printers, printers WHERE carts2printers.cartID = %s AND printers.printerID = carts2printers.printerID", GetSQLValueString($targetCart_rsCart2Printer, "int"));
$rsCart2Printer = mysql_query($query_rsCart2Printer, $connCompats) or die(mysql_error());
$row_rsCart2Printer = mysql_fetch_assoc($rsCart2Printer);
$totalRows_rsCart2Printer = mysql_num_rows($rsCart2Printer);?>
<?php
// WA Application Builder Delete
if (isset($_POST["Delete_x"])) // Trigger
{
$WA_connection = $connCompats;
$WA_table = "cartridges";
$WA_redirectURL = "cartridges_ListAll.php";
$WA_keepQueryString = false;
$WA_fieldNamesStr = "cartID";
$WA_columnTypesStr = "none,none,NULL";
$WA_fieldValuesStr = "".((isset($_POST["WADADeleteRecordID"]))?$_POST["WADADeleteRecordID"]:"") ."";
$WA_comparisonStr = "=";
$WA_fieldNames = explode("|", $WA_fieldNamesStr);
$WA_fieldValues = explode("|", $WA_fieldValuesStr);
$WA_columns = explode("|", $WA_columnTypesStr);
$WA_comparisions = explode("|", $WA_comparisonStr);
$WA_connectionDB = $database_connCompats;
mysql_select_db($WA_connectionDB, $WA_connection);
if (!session_id()) session_start();
$deleteParamsObj = WA_AB_generateWhereClause($WA_fieldNames, $WA_columns, $WA_fieldValues, $WA_comparisions);
$WA_Sql = "DELETE FROM `" . $WA_table . "` WHERE " . $deleteParamsObj->sqlWhereClause;
$MM_editCmd = mysql_query($WA_Sql, $WA_connection) or die(mysql_error());
if ($WA_redirectURL != "") {
if ($WA_keepQueryString && $WA_redirectURL != "" && isset($_SERVER["QUERY_STRING"]) && $_SERVER["QUERY_STRING"] !== "" && sizeof($_POST) > 0) {
$WA_redirectURL .= ((strpos($WA_redirectURL, '?') === false)?"?":"&").$_SERVER["QUERY_STRING"];
}
header("Location: ".$WA_redirectURL);
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><!-- InstanceBegin template="/Templates/2ColTemplate.dwt" codeOutsideHTMLIsLocked="false" -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- InstanceBeginEditable name="doctitle" -->
<title>Delete a cartridge</title>
<!-- InstanceEndEditable -->
<link href="../styles/compats_basics.css" rel="stylesheet" type="text/css" /><!--[if IE 5]>
<style type="text/css">
/* place css box model fixes for IE 5* in this conditional comment */
.thrColFixHdr #sidebar1 { width: 180px; }
.thrColFixHdr #sidebar2 { width: 190px; }
</style>
<![endif]--><!--[if IE]>
<style type="text/css">
/* place css fixes for all versions of IE in this conditional comment */
.thrColFixHdr #sidebar2, .thrColFixHdr #sidebar1 { padding-top: 30px; }
.thrColFixHdr #mainContent { zoom: 1; }
/* the above proprietary zoom property gives IE the hasLayout it needs to avoid several bugs */
</style>
<![endif]-->
<!-- InstanceBeginEditable name="head" -->
<link href="../WA_DataAssist/styles/Elemental_Slate.css" rel="stylesheet" type="text/css" />
<link href="../WA_DataAssist/styles/Verdana.css" rel="stylesheet" type="text/css" />
<!-- InstanceEndEditable -->
</head>
<body class="twoColFixHdr">
<div id="container">
<div id="header">
<div id="logo"><img src="../images/compatsLogo02.gif" width="215" height="46" alt="Compats" /></div>
<h1>Compats</h1>
<!-- end #header -->
</div>
<div id="sidebar1"><!-- InstanceBeginEditable name="sideBar1Content" -->
<?php require_once('../includes/nav_Admin.php'); ?>
<!-- InstanceEndEditable -->
<!-- end #sidebar1 --></div>
<div id="mainContent"><!-- InstanceBeginEditable name="mainContent" -->
<div id="breadcrumbs"><p><a href="index.php">Admin Home</a> > Delete a cartridge</p></div>
<h1>Delete a cartridge</h1>
<?php if ($totalRows_rsCart2Printer == 0) { // Show if recordset empty ?>
<div class="WADADeleteContainer">
<?php if ($totalRows_WADAcartridges > 0) { // Show if recordset not empty ?>
<form action="cartridges_Delete.php?cartID=<?php echo(rawurlencode($row_WADAcartridges['cartID'])); ?>" method="post" name="WADADeleteForm" id="WADADeleteForm">
<p class="WADAMessage">Are you sure you want to delete the following record?</p>
<table class="WADADataTable" cellpadding="0" cellspacing="0" border="0">
<tr>
<th class="WADADataTableHeader">Compats Ref:</th>
<td class="WADADataTableCell"><?php echo($row_WADAcartridges['compatsRef']); ?></td>
</tr>
<tr>
<th class="WADADataTableHeader">M/F Part No:</th>
<td class="WADADataTableCell"><?php echo($row_WADAcartridges['cartCode']); ?></td>
</tr>
<tr>
<th class="WADADataTableHeader">Description:</th>
<td class="WADADataTableCell"><?php echo($row_WADAcartridges['cartDescr']); ?></td>
</tr>
<tr>
<th class="WADADataTableHeader">Colour:</th>
<td class="WADADataTableCell"><?php echo($row_WADAcartridges['cartColor']); ?></td>
</tr>
<tr>
<th class="WADADataTableHeader"> </th>
<td class="WADADataTableCell"><img src="../images/<?php echo $row_WADAcartridges['cartImage']; ?>" /></td>
</tr>
</table>
<div class="WADAButtonRow">
<table class="WADADataNavButtons" border="0" cellpadding="0" cellspacing="0">
<tr>
<td class="WADADataNavButtonCell" nowrap="nowrap"><input type="image" name="Delete" id="Delete" value="Delete" alt="Delete" src="../WA_DataAssist/images/Slate/Elemental_delete.gif" /></td>
<td class="WADADataNavButtonCell" nowrap="nowrap"><a href="cartridges_ListAll.php" title="Cancel"><img border="0" name="Cancel" id="Cancel" alt="Cancel" src="../WA_DataAssist/images/Slate/Elemental_cancel.gif" /></a></td>
</tr>
</table>
<input name="WADADeleteRecordID" type="hidden" id="WADADeleteRecordID" value="<?php echo(rawurlencode($row_WADAcartridges['cartID'])); ?>" />
</div>
</form>
<?php } // Show if recordset not empty ?>
<?php if ($totalRows_WADAcartridges == 0) { // Show if recordset empty ?>
<div class="WADANoResults">
<div class="WADANoResultsMessage">No record found.</div>
</div>
<?php } // Show if recordset empty ?>
</div>
<?php } // Show if recordset empty ?>
<?php if ($totalRows_rsCart2Printer > 0) { // Show if recordset not empty ?>
<h1>Warning!!</h1>
<p>This cartridge is still associated with the following printers. You must
delete that association before you can delete the cartridge.</p>
<p> </p>
<form id="del_MultiplesForm" name="del_MultiplesForm" method="post" action="">
<table width="300">
<?php do { ?>
<tr>
<td><?php echo $row_rsCart2Printer['printerName']; ?></td>
<td><input type="checkbox" name="del_MultiCheck" id="del_MultiCheck" /></td>
</tr>
<?php } while ($row_rsCart2Printer = mysql_fetch_assoc($rsCart2Printer)); ?>
<tr>
<td><input type="submit" name="btn_DelMultiples" id="btn_DelMultiples" value="Delete Selected" /></td>
<td> </td>
</tr>
</table>
</form>
<p> </p>
<?php } // Show if recordset not empty ?>
<!-- InstanceEndEditable -->
<!-- end #mainContent --></div>
<!-- This clearing element should immediately follow the #mainContent div in order to force the #container div to contain all child floats --><br class="clearfloat" />
<div id="footer">
<p>© www.compats.com <?php echo date("Y") ?></p>
<!-- end #footer --></div>
<!-- end #container --></div>
</body>
<!-- InstanceEnd --></html>
<?php
mysql_free_result($WADAcartridges);
mysql_free_result($rsCart2Printer);
?>