Wade Posted December 18, 2006 Share Posted December 18, 2006 Hi there, I'm new to php and am hoping someone here can help.I am developing an in-house contact management application, so that people can lookup contact or edit them as needed.Each contact can be associated to multiple communities, and each community can have 15 or more items that can be set, I have the checkboxes in an array that I'm retrieving with $_POST but the data does seem right... I'll post snippets of the for m and the save.php any help is appreciated.The following is the form[code]<?php mysql_data_seek( $result1, 0 );while ($row1 = mysql_fetch_assoc($result1)) { ?><input type="hidden" name="rowData[]" value="<?php echo $row1 ?>" /><tr><td><input type="text" value="<?php echo $row1['CName']; ?>" name="CName[]" size="15" /></td><td><input type="checkbox" name="HOContact[]" <?php if($row1["HOContact"]){echo " CHECKED";} ?> /></td><td><input type="checkbox" name="HOAcctContact[]" <?php if($row1["HOAcctContact"]){echo " CHECKED";} ?> /></td><td><input type="checkbox" name="MUAreaMgr[]" <?php if($row1["MUAreaMgr"]){echo " CHECKED";} ?> /></td><td><input type="checkbox" name="StAreaMgr[]" <?php if($row1["StAreaMgr"]){echo " CHECKED";} ?> /></td><td><input type="checkbox" name="MFAreaMgr[]" <?php if($row1["MFAreaMgr"]){echo " CHECKED";} ?> /></td><td><input type="checkbox" name="SCContact[]" <?php if($row1["SCContact"]){echo " CHECKED";} ?> /></td><td><input type="checkbox" name="VMAttendee[]" <?php if($row1["VMAttendee"]){echo " CHECKED";} ?> /></td><td><input type="checkbox" name="ConMgr[]" <?php if($row1["ConMgr"]){echo " CHECKED";} ?> /></td><td><input type="checkbox" name="SiteSuper[]" <?php if($row1["SiteSuper"]){echo " CHECKED";} ?> /></td><td><input type="checkbox" name="SiteSuperAsst[]" <?php if($row1["SiteSuperAsst"]){echo " CHECKED";} ?> /></td><td><input type="checkbox" name="VIPOpenInvite[]" <?php if($row1["VIPOpenInvite"]){echo " CHECKED";} ?> /></td><td><input type="checkbox" name="CCCLunchInvite[]" <?php if($row1["CCCLunchInvite"]){echo " CHECKED";} ?> /></td></tr><?php } ?>[/code]Next I have the save routine[code]$rowData = $_POST["rowData"];$CName = $_POST["CName"];$HOContact = $_POST["HOContact"];$HOAcctContact = $_POST["HOAcctContact"];$MUAreaMgr = $_POST["MUAreaMgr"];$StAreaMgr = $_POST["StAreaMgr"];$MFAreaMgr = $_POST["MFAreaMgr"];$SCContact = $_POST["SCContact"];$VMAttendee = $_POST["VMAttendee"];$ConMgr = $_POST["ConMgr"];$SiteSuper = $_POST["SiteSuper"];$SiteSuperAsst = $_POST["SiteSuperAsst"];$VIPOpenInvite = $_POST["VIPOpenInvite"];$CCCLunchInvite = $_POST["CCCLunchInvite"];$n = count($rowData);$i = 0;while ($i < $n){$query2 = "UPDATE communities SET HOContact='" . $HOContact[$i] . "',HOAcctContact='" . $HOAcctContact[$i] . "',MUAreaMgr='" . $MUAreaMgr[$i] . "',StAreaMgr='" . $StAreaMgr[$i] . "',MFAreaMgr='" . $MFAreaMgr[$i] . "',SCContact='" . $SCContact[$i] . "',VMAttendee='" . $VMAtttendee[$i] . "',ConMgr='" . $ConMgr[$i] . "',SiteSuper='" . $SiteSuper[$i] . "',SiteSuperAsst='" . $SiteSuperAsst[$i] . "',VIPOpenInvite='" . $VIPOpenInvite[$i] . "',CCCLunchInvite='" . $CCCLunchInvite[$i] . "' WHERE CName=" . $CName[$i] . " AND ContactID=" . $id;echo("Exisiting record SQL for Communities Table: " . $query2 . "<br><br>");$i++;}[/code]These are not full listings of the php files, only what 'I think' is relevant. I can post more if needed. Link to comment https://forums.phpfreaks.com/topic/31112-multple-row-with-multiple-values-form-to-update-mysql-data/ Share on other sites More sharing options...
Wade Posted December 18, 2006 Author Share Posted December 18, 2006 I guess I forgot to state the problem.It seems the data is posted properly, however it's not staying in the right order. if the checkbox is not 'on' then it messes up the data.Is there a better 'cleaner' way to do this?Thanks Link to comment https://forums.phpfreaks.com/topic/31112-multple-row-with-multiple-values-form-to-update-mysql-data/#findComment-143652 Share on other sites More sharing options...
Wade Posted December 18, 2006 Author Share Posted December 18, 2006 *bump* Link to comment https://forums.phpfreaks.com/topic/31112-multple-row-with-multiple-values-form-to-update-mysql-data/#findComment-143753 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.