Good Day All,
Got a small newbie problem here using PHP, MySQL and DWMX2004.
I'm building a file tracking system for a small company. The site is completed except for a the section where I want it display any files that have been completed. I created a form via Dreamweaver and followed the Update Wizard under Insert>Application Objects. Once I completed the Wizard, it gave me code for one record. I need to spread it over multiple columns and update in one action. Is this possible?
For instance I have a multi-column table with File Number (not ID), File Name, Author, etc. Along this same header row, there are also columns describing where the checkboxes go. I have the appropriate dynamic data populating the fields in a table. Checkboxes fill the rest. Essentially, all I need to do is pass the checkboxes as text to be filled into the various fields in my DB.
Here is my 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);
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Welcome</title><link rel="SHORTCUT ICON" href="images/icon.ico">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="bpstyles.css" rel="stylesheet" type="text/css">
</head>
<body bgcolor="#FFFFFF" text="#666666" vlink="#333366" alink="#663333">
<table width="100%" border="0" cellspacing="2" cellpadding="2">
<tr>
<td width="2%" height="419" valign="top">
<!-- Left Table begin -->
<table width="100%" height="100%" border="0" cellpadding="2" cellspacing="0" bgcolor="#99CCFF" valign="top">
<tr>
<td height="38" align="center" bgcolor="#FFFFFF"><a href="http://www.gtech.com"><img src="images/gtechlogo.gif" border="0"></a></td>
</tr>
<tr>
<td valign="top">
<!-- Links Table -->
<div align="center"></div>
<table width="100%" border="0" cellspacing="2" cellpadding="2">
<tr>
<td class="linksHeader"><img src="images/links.gif" width="137" height="20"></td>
</tr>
<tr>
<td height="5"background="images/line.gif"> </td>
</tr>
<tr>
<td class="navBarLinks"><a href="http://home.com/"><font color="#FFFFFF">Home</font></a></td>
</tr>
<tr>
<td class="navBarLinks"><a href="http://www.www.com"><font color="#FFFFFF">Link</font></a></td>
</tr>
<tr>
<td class="navBarLinks"><a href="http://www.www.com"><font color="#FFFFFF">Documentum</font></a></td>
</tr>
<tr>
<td class="navBarLinks"><a href="http://riweb6/ic2.asp?http://www.www.com"><font color="#FFFFFF">Link</font></a></td>
</tr>
<tr>
<td class="navBarLinks"><a href="http://www.www.com"><font color="#FFFFFF">Link</font></a></td>
</tr>
<tr>
<td class="navBarLinks"><a href="help.html"><font color="#FFFFFF">Help</font></a></td>
</tr>
<tr>
<td class="navBarLinks"><img src="images/pad.gif" width="137" height="175"></td>
</tr>
</table>
<!-- Links Table End -->
</td>
</tr>
</table>
<!-- Left Table End -->
</td>
<td width="98%" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<!--Search Bar Begin -->
<td height="32" valign="top">
<table width="100%" border="0" cellpadding="2" cellspacing="0" bgcolor="#CCCC99" class="boilerNavBarText">
<tr>
<td width="96%" height="28" align="right" valign="middle" class="boilerNavBarText">
<a href="http://www.www.com/"><font color="#996633">Home</font></a>
| <a href="http://www.www.com"><font color="#996633">www.www.com</font></a>
| <a href="mailto:master@www.com?subject=Business%20Pro posals%20Tracking"><font color="#996633">Feedback</font></a></td>
<td width="2%" bgcolor="#FFFFFF"><img src="images/pix.gif" width="1" height="1"></td>
<td width="2%" valign="top">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr class="button">
<form name="proposal" method="post" action="searchform3.php"><td width="70%" valign="middle">
<input name="textfield" type="text" class="formTextField" size="20" maxlength="50">
</td>
<td width"5%"><img src="images/pix.gif" width="1" height="1"></td>
<td width="30%" align="center" valign="middle"><input name="search" type="submit" value="Search" class="button"></td></form>
</tr>
</table></td>
</tr>
</table></td>
</tr>
<!--Search Bar End -->
<tr>
<!--Logo Table Begin -->
<td><table width="100%" border="0" cellspacing="3" cellpadding="3">
<tr>
<td><img src="images/bplogo.gif" width="367" height="43"></td>
</tr>
<tr height="5px">
<td align="left" valign="top" background="images/spacer.gif"><img src="images/pix.gif" width="1" height="1" align="top"></td>
</tr>
<tr>
<td align="right" class="logoModule">Proposal Tracking | Exhibit
Tracking</td>
</tr>
</table></td>
<!--Logo Table End -->
</tr>
<tr>
<td><table width="100%" border="0" cellspacing="2" cellpadding="2">
<tr class="textBody" background="images/spacer.gif">
<td colspan="2"><img src="images/pix.gif" width="1" height="1"></td>
</tr>
<tr class="textBody">
<td width="60%">Welcome to Tracking. Current
proposals and due dates are listed below. Click on proposal
name to view status.</td>
<td width="40%" align="right" valign="bottom"><a href="propadminindex.php" class="textBody">Admin
Page</a> | <a href="logpass.php"><font color="#666666">Admin
Login</font></a></td>
</tr>
</table>
</td>
</tr>
<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>
</td>
</tr>
</table></td>
</tr>
</table>
<table width="100%" border="0" cellpadding="2" cellspacing="2" bgcolor="#6699CC" class="footerText">
<tr>
<td>© Copyright 2004</td>
<td align="right"><a href="http://www.www.com"><font color="#FFFFFF">Privacy
Policy</font></a></td>
</tr>
</table>
</body>
</html>
<?php
mysql_free_result($propstatus);
?>
----------END-------------
Is there a way to mass-populate with one form or am I going to have to update each one individually? I hope that I have been clear.
Thanks in advance.