close ad
WARNING: Do Not Install the DREAMWEAVER CC 2017 or 2018 Update »
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Difficulty loading existing data into an Edit Form.

Thread began 9/11/2014 8:05 am by Andrew | Last modified 4/02/2015 2:55 pm by Ray Borduin | 1619 views | 14 replies |

Andrew

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

Sign in to reply to this post

Jason ByrnesWebAssist

you have to bind the forms to the coresponding recordset elements.

Select each form element, int he property inspector, click the lightning bolt next to Initial Value and select the coresponding recordset column


for the select lists, click the dynamic button and in the Select Item Equal To, select the corresponding column from the rsItems recordset.

Sign in to reply to this post

Andrew

Hi Jason

Thank you - that worked.

Data is now loaded and can be amended.

Submitting gets
Notice: Undefined variable: rsItems in C:\wamp_php5_5\www\sheffieldarchives\admin\edit.php on line 9
Fatal error: Call to a member function getColumnVal() on a non-object in C:\wamp_php5_5\www\sheffieldarchives\admin\edit.php on line 9

The relevant piece of code is:
$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("itemTitle", "s", "".((isset($_POST["itemName"]))?$_POST["itemName"]:"") ."", "WA_DEFAULT");
$UpdateQuery->bindColumn("itemDescription", "s", "".((isset($_POST["itemDescription"]))?$_POST["itemDescription"]:"") ."", "WA_DEFAULT");
.......

and rsItems is:
<?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();
?>

I used to do this with a DW Wizard - that's why I'm struggling (I don't understand php).

Thanks in anticipation.

Andrew

Sign in to reply to this post

Jason ByrnesWebAssist

send the full page so i can see the code in context.

Sign in to reply to this post

Andrew

File attached

Sign in to reply to this post

Jason ByrnesWebAssist

the update code is before the code block for the recordset.

instead of using the recordset binding for the ID, create a hidden form element, bind that to the Id column from the recordset, then in the update behavior, set the filter column to use the hidden form element.

on the binding tab, you should not bind the ID column to anything.

Sign in to reply to this post

Andrew

That's solved it!

Thank you very much!

Sign in to reply to this post

Jason ByrnesWebAssist

you're welcome

Sign in to reply to this post

Ian

Continuing update problem

Apologies if bad form to re-open an old thread but seems appropriate as it seems an identical problem and suggestions above don;t seem to have solved it for me.

I have a record update form which is more or less identical to the add record form (other than dynamic code and minor detail)
I open the update form in Dreamweaver 5.5 and create a record set.
Server behaviours, +, Web Assist, MySQLi, Data Management, MySQLi Update Record.
Trigger – Button: re_button pressed
Connection – PrioryTerrier
Update Table – registers
Lookup column – re_index (default value)
Column type – Integer (default value)
Lookup value - $_GET[‘re_index’} (default value)
After updating go to – list_register_record.php

Column bindings
re_index –
Value = <?php echo((isset($_POST["re_register"]))?$_POST["re_register"]:"") ?>
Submit as Text, Blank value Db Default

Same (apart from field names) for re_period_from, re_period_to, re_location, and date_recorded
date_update has blank value set to Current Date

Testing the page at this stage allows me to correctly select an existing record but the update form does not show existing data but I can complete the fields and these are recorded, over writing the existing record if something new entered or leaving the initial value if nothing new entered in the field.

I then go back to programming and go through the form, selecting each field in turn and clicking the lightning bolt by Initial value in the Properties Inspector and selecting the matching name from the options shown under Form. This includes the hidden field.

Testing again results in the same as before – edit is possible but it is done “blind” as before as no past data is shown.

Because of replies above, I started again, this time first creating a Record set, then binding fields as appropriate, including binding the Id field to a hidden form element as suggested in the above forum thread.
That just digs a bigger hole for myself!

As you will gather, I don’t really know what I am doing when it comes to PHP and MySQL but know enough to have created bega.org.uk for the local church to save them £5000 for a commercial package which is worth it but we can’t afford.

I have attached the offending file!

Attached Files
update_registers_record.php
Sign in to reply to this post

Jason ByrnesWebAssist

I'll need to troubleshoot directly, see the private message section.

Sign in to reply to this post
loading

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...