close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

2 update server behaviors on 1 page??

Thread began 1/20/2010 11:28 am by troyd | Last modified 1/22/2010 5:51 pm by Eric Mittman | 1254 views | 6 replies |

troyd

2 update server behaviors on 1 page??

I'm reading in other threads that this is ok to do. And I have all the other pages (Results, Details, Delete, Insert), working fine so far. But with the Update page, I've ran into some difficulties.

First, when performing an update using the original update form, it updates with success. So my second update form doesn't seem to be killing the first form.

But when I click "Update" on the record for the second table and then try to update that record, it does nothing. Well, it goes to the Details page but without any update being performed to the table. And I also noticed that the URL is missing the actual ID. It just has ?id= after the url when using the second form.

I have this page set using 2 show if statements. One for each form. This is working great. If the "Update" button for the record for form 1 is clicked, then it fills in the form and the second form is hidden. And vise-versa.

The record value and redirect for the first form is

php:
$WA_redirectURL = "tblMyrecords_Detail.php?id=".((isset($_POST["WADAUpdateRecordID"]))?$_POST["WADAUpdateRecordID"]:"")  ."";


$WA_where_fieldValuesStr = "".((isset($_POST["WADAUpdateRecordID"]))?$_POST["WADAUpdateRecordID"]:"")  ."";



What should it be for the second update form? Do I need to change WADAUpdateRecordID to WADAUpdateRecordID2?

Both tables use "id" as the key column. So it seems I have a session conflict, maybe?
The recordsets WHERE statement is as follows,

SELECT *
FROM tblMyFirstTable
WHERE id = colname

SELECT *
FROM tblMySecondTable
WHERE id = colname

Thanks in advance,
TroyD

Sign in to reply to this post

troyd

By the way, here is my sql for both record sets.

php:
<?php $Paramid_rsTable1 "-1";

if (isset(
$_GET['id'])) {
  
$Paramid_rsTable1 = (get_magic_quotes_gpc()) ? $_GET['id'] : addslashes($_GET['id']);
}
mysql_select_db($database_dbCMS$dbCMS);
$query_rsTable1 sprintf("SELECT * FROM tblTable1 WHERE id = %s"GetSQLValueString($Paramid_rsTable1"int"));
$rsTable1 mysql_query($query_rsTable1$dbCMS) or die(mysql_error());
$row_rsTable1 mysql_fetch_assoc($rsTable1);
$totalRows_rsTable1 mysql_num_rows($rsTable1);

$colname_rsTable2 "-1";
if (isset(
$_GET['id'])) {
  
$colname_rsTable2 = (get_magic_quotes_gpc()) ? $_GET['id'] : addslashes($_GET['id']);
}
mysql_select_db($database_dbCMS$dbCMS);
$query_rsTable2 sprintf("SELECT * FROM tblTable2 WHERE id = %s"GetSQLValueString($colname_rsTable2"int"));
$rsTable2 mysql_query($query_rsTable2$dbCMS) or die(mysql_error());
$row_rsTable2 mysql_fetch_assoc($rsTable2);
$totalRows_rsTable2 mysql_num_rows($rsTable2);?>



TroyD

Sign in to reply to this post

Eric Mittman

It seems that there may be a problem regarding the value that is referenced for the id. Does your second form have this element in it that holds the id of the record to be updated? It may be easier to debug the page by looking at the code on it. Please post back and include a copy of the page in a zip archive so we can take a look.

Sign in to reply to this post

troyd

Well, it has the hidden field that echos the id for that recordset, if that's what you are referring to. The form fills in with all the correct information. I even changed the hidden field to a text field just so I could see the id for myself. Plus, the url contains the id for the record just before I click the update button. Then it's gone.

Here's the update page with both forms.

Thanks,
TroyD

Attached Files
tblavailablehh_update.php.zip
Sign in to reply to this post

Eric Mittman

It looks like there are two problems here. The first issue is that your second update is using the posted WADAUpdateRecordID value from the first form. This will not work since this values is not present if the second form is used. The name of the element that holds the id in the second form is WADAUpdateRecordID2. You will need to edit your second update to make use of this form element.

The second problem is that the hidden form field that your second form is using for the id is not being set, here is the field from the second form:

html:
<input name="WADAUpdateRecordID2" type="hidden" id="WADAUpdateRecordID2" value="" />



You will need to set the value of this element in the second form to the id from the recordset for the record that is being updated like this:

php:
<input name="WADAUpdateRecordID2" type="hidden" id="WADAUpdateRecordID2" value="<?php echo(rawurlencode($row_rsStickyHH['id'])); ?>" />
Sign in to reply to this post

troyd

Eric,

Amazing. I can't believe I missed that. I feel like an idiot. And you caught it right away. Thanks so much, it's working perfectly now. I scrubbed through all the update code and form functions and ended up missing a simple field value. Another lesson learned.

Thanks again,
TroyD

Sign in to reply to this post

Eric Mittman

You welcome, sometime it just helps to have another set of eyes look at things.

Sign in to reply to this post

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...