I'm looking for help with a way to update multiple records in a DB.
I posted this before but I think that I was rather vague on my request.
I need a way to pass the info to the MySQL DB. I've been using DW2004MX and its Update Record Wizard. Unfortunately it doesn't allow me to seed information across multiple records,it only does one at a time. I need a way to pass the info across multiple records.
The sample format is as follows:
DocName | Doc Number | Doc Writer | Format | Edit | Print | Complete|
Corporate| 1.1 | Name | X | X | X | X |
Source | 1.2 | Name | X | X | 0 | 0 |
Terms | 1.3 | Name | X | 0 | 0 | 0 |
Document| 2.1 | Name | X | X | X | 0 |
|Update|
(X=checked 0=not checked.)
Now the first three columns are pulled from the database while at the same time the DocName is the unique key that has been passed from the search page via "recordID?".
There is another column that has the project name but I left that out for example purposes. Now I need a way to send the multi check boxes to the database and equaling "1111111111".
I have this all nested in an HTML form with hidden fields to pass the information along. I think I've missed something. Everytime I hit the update button I get sent back to the update page and nothing gets inserted into the DB. Also here's a copy of the code:
------------Begin-----------------------------
<?php require_once('Connections/MySQL.php'); ?>
<?php
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $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;
}
$editFormAction = $SERVER['PHP_SELF'];
if (isset($SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
if ((isset($POST["MM_update"])) && ($POST["MM_update"] == "form2")) {
$updateSQL = sprintf("UPDATE proposals SET com_edt=%s, fst_red=%s, format=%s, final=%s, cpy_cnt=%s, trn_snt=%s, trn_rcv=%s WHERE proposal=%s",
GetSQLValueString($POST['com_edt'], "text"),
GetSQLValueString($POST['fst_red'], "text"),
GetSQLValueString($POST['format'], "text"),
GetSQLValueString($POST['final'], "text"),
GetSQLValueString($POST['cpy_cnt'], "text"),
GetSQLValueString($POST['trn_snt'], "text"),
GetSQLValueString($POST['trn_rcv'], "text"),
GetSQLValueString($POST['proposal'], "text"));
mysql_select_db($database_MySQL, $MySQL);
$Result1 = mysql_query($updateSQL, $MySQL) or die(mysql_error());
$updateGoTo = "propadminindex.php";
if (isset($SERVER['QUERY_STRING'])) {
$updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
$updateGoTo .= $SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $updateGoTo));
}
$colname_propstatus = "1";
if (isset($GET['recordID'])) {
$colname_propstatus = (get_magic_quotes_gpc()) ? $GET['recordID'] : addslashes($_GET['recordID']);
}
mysql_select_db($database_MySQL, $MySQL);
$query_propstatus = sprintf("SELECT * FROM proposals WHERE proposal = '%s'", $colname_propstatus);
$propstatus = mysql_query($query_propstatus, $MySQL) or die(mysql_error());
$row_propstatus = mysql_fetch_assoc($propstatus);
$totalRows_propstatus = mysql_num_rows($propstatus);
?>
<tr>
<td valign="top"><form method="post" name="form2" action="<?php echo $editFormAction; ?>">
<table width="100%" border="0" cellpadding="3" cellspacing="0" class="tableFormat">
<tr class="tableHeader">
<td>Proposal</td>
<td class="tableHeader">Section Number</td>
<td class="tableHeader">Section Name</td>
<td class="tableHeader">Section Writer</td>
<td class="tableHeader">Compliance/ Edit</td>
<td class="tableHeader">first Read</td>
<td class="tableHeader">Format</td>
<td class="tableHeader">Final</td>
<td class="tableHeader">Copy Center</td>
<td class="tableHeader">Translation Sent</td>
<td class="tableHeader">Translation Received</td>
</tr>
<?php do { ?>
<tr>
<td class="tableNoBottomNoRightBorder"><?php echo $row_propstatus['proposal']; ?></td>
<td class="tableNoBottomNoRightBorder"><?php echo $row_propstatus['sec_num']; ?></td>
<td class="tableNoBottomNoRightBorder"><?php echo $row_propstatus['sec_nam']; ?></td>
<td align="center" class="tableNoBottomNoRightBorder"><?php echo $row_propstatus['sec_wrt']; ?></td>
<td align="center" class="tableProp"><input type="checkbox" name="com_edt" value="" <?php if (!(strcmp($row_propstatus['com_edt'],1111111111))) {echo "checked";} ?>></td>
<td align="center" class="tableProp"><input type="checkbox" name="fst_red" value="" <?php if (!(strcmp($row_propstatus['fst_red'],1111111111))) {echo "checked";} ?>></td>
<td align="center" class="tableProp"><input type="checkbox" name="format" value="" <?php if (!(strcmp($row_propstatus['format'],1111111111))) {echo "checked";} ?>></td>
<td align="center" class="tableProp"><input type="checkbox" name="final" value="" <?php if (!(strcmp($row_propstatus['final'],1111111111))) {echo "checked";} ?>></td>
<td align="center" class="tableProp"><input type="checkbox" name="cpy_cnt" value="" <?php if (!(strcmp($row_propstatus['cpy_cnt'],1111111111))) {echo "checked";} ?>></td>
<td align="center" class="tableProp"><input type="checkbox" name="trn_snt" value="" <?php if (!(strcmp($row_propstatus['trn_snt'],1111111111))) {echo "checked";} ?>></td>
<td align="center" class="tableProp"><input type="checkbox" name="trn_rcv" value="" <?php if (!(strcmp($row_propstatus['trn_rcv'],1111111111))) {echo "checked";} ?>></td>
</tr>
<?php } while ($row_propstatus = mysql_fetch_assoc($propstatus)); ?>
</table>
<p>
<input type="hidden" name="MM_update" value="form2">
<input type="hidden" name="proposal" value="<?php echo $row_propstatus['proposal']; ?>">
<input type="submit" value="Update record">
</p>
</form>
--------------------END---------------------------------
I hope that I've clarified my request better. Any help would be greatly appreciated. Thanks again.