Current location: Hot Scripts Forums » Programming Languages » PHP » Help with multipart update form into MySQL DB...


Help with multipart update form into MySQL DB...

Reply
  #1 (permalink)  
Old 07-01-04, 02:42 PM
jimb575 jimb575 is offline
New Member
 
Join Date: Jul 2004
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Help with multipart update form into MySQL DB...

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 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. Thanks again.
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP Form to update a MySQL database? Scoobler PHP 9 09-04-08 01:41 AM
Help with updating a multiple checkbox form to a MySQL DB jimb575 PHP 1 01-31-06 08:04 PM
Easy form drop-down box update dave111 Script Requests 1 04-14-04 12:36 PM
MySql update form script? dihan PHP 8 01-10-04 03:35 AM
PHP to MySQL script question...(using a field to update info in MySQL) DisneyFan25863 PHP 4 11-02-03 03:31 AM


All times are GMT -5. The time now is 05:07 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.