Difficulty loading existing data into an Edit Form.
Hi Jason
Using the WebAssist Update Record feature, I'm having difficulty loading existing data into an Edit Form.
The link that should load the data is:
<a href="edit.php?itemID=<?php echo($rsItems->getColumnVal("itemID")); ?>">Edit this item</a>
and on the Edit Page, this appears in the browser address with the correct value for the item ID. However no data is loaded into the Edit Form.
The php code at the top of the Edit Page reads ....
<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$UpdateQuery = new WA_MySQLi_Query($connsheffieldarchives);
$UpdateQuery->Action = "update";
$UpdateQuery->Table = "items";
$UpdateQuery->bindColumn("itemID", "s", "".($rsItems->getColumnVal("itemID")) ."", "WA_DEFAULT");
$UpdateQuery->bindColumn("itemNo", "i", "".((isset($_POST["itemNo"]))?$_POST["itemNo"]:"") ."", "WA_DEFAULT");
.
.
.
$UpdateQuery->bindColumn("publicPrivate", "s", "".((isset($_POST["public"]))?$_POST["public"]:"") ."", "WA_DEFAULT");
$UpdateQuery->addFilter("itemID", "=", "i", "".($_GET['itemID']) ."");
$UpdateQuery->execute();
$UpdateGoTo = "admin_menu.php";
if (function_exists("rel2abs")) $UpdateGoTo = $UpdateGoTo?rel2abs($UpdateGoTo,dirname(__FILE__)):"";
$UpdateQuery->redirect($UpdateGoTo);
}
?>
<?php
$rsItems = new WA_MySQLi_RS("rsItems",$connsheffieldarchives,1);
$rsItems->setQuery("SELECT * FROM items WHERE itemID = ?");
$rsItems->bindParam("i", "".(isset($_GET['itemID'])?$_GET['itemID']:"") ."", "-1"); //colname
$rsItems->execute();?>
Within the form, the data should appear in form fields that read (typically)
<input type="text" name="itemNo" id="itemNo" /> for text
and
<select name="decade" id="decade">
<?php
while(!$rsDecade->atEnd()) { //dyn select
?>
<option value="<?php echo($rsDecade->getColumnVal("decadeID")); ?>"<?php if (!(strcmp($rsDecade->getColumnVal("decadeID"), ($rsDecade->getColumnVal("decadeID"))))) {echo "selected=\"selected\"";} ?>><?php echo($rsDecade->getColumnVal("decadeName")); ?></option>
<?php
$rsDecade->moveNext();
} //dyn select
$rsDecade->moveFirst();
?>
</select> for tables
If it's any help, the relevant pages can be found at
http://archives.shearwaterwebdesign.co.uk/admin/edit_listing.php
with the link on the bottom of the following page.
Thanks in anticipation