Copy link to clipboard
Copied
Hi folks,
I am trying to adapt a page to offer the option to update multiple records on one page.
The intention is to edit FAQ categories which are contained in a table with just two fields - the category and an id.
The page lists each categories in a form with a submit button which is then repeated for each record in the recordset.
Unfortunately my plan didn't work and only the first record updates as intended.
Can anyone suggest how I can make it work?
Here's the code I have so far.
************** The Update Code *****************
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
if (!isset($mm_abort_edit) || !$mm_abort_edit) {
if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) {
$updateSQL = sprintf("UPDATE faq_categories SET category=%s WHERE id=%s",
GetSQLValueString($_POST['category'], "text"),
GetSQLValueString($_POST['id'], "int"));
mysql_select_db($database_con_mysite, $con_mysite);
$Result1 = mysql_query($updateSQL, $con_mysite) or die(mysql_error());
$updateGoTo = "faq-category-edit.php
if (isset($_SERVER['QUERY_STRING'])) {
$updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
$updateGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $updateGoTo));
}}
************** Update Code Ends *****************
************** The Form *****************
<form name="frm_editcategory" id="frm_editcategory" method="POST" action="<?php echo $editFormAction; ?>">
<?php do { ?>
<fieldset>
<input name="id" type="hidden" value="<?php echo $row_rs_faqcategory['id']; ?>" />
<input name="category" type="text" class="formrightcolumn" value="<?php echo $row_rs_faqcategory['category']; ?>" />
<input name="save" type="submit" class="submitbutton" id="save" value="save" />
</fieldset>
<input type="hidden" name="MM_update" value="form1" />
<?php } while ($row_rs_faqcategory = mysql_fetch_assoc($rs_faqcategory)); ?>
</form>
************** The Form Ends *****************
Cheers
Dave
Copy link to clipboard
Copied
Surely someone must be able to figure this out?
Copy link to clipboard
Copied
What does debugging tell you? What's the value of each of the variables? Did you try using regular echo statements to monitor what's going on? That's what I always do whenever I am stuck in my PHP coding.
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more