close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

update multiple records strange toggle effect behaviour

Thread began 5/21/2009 3:12 am by office377308 | Last modified 5/21/2009 9:26 pm by office377308 | 2513 views | 4 replies |

office377308

update multiple records strange toggle effect behaviour

It seems I can't figure out what's wrong with my setup, at least I am lost.

I want to update a mysql table like

CREATE TABLE IF NOT EXISTS `stories` (
`stories_id` mediumint(6) NOT NULL auto_increment,
`categories_id` mediumint(6) NOT NULL,
`stories_language_id` tinyint(2) NOT NULL,
`stories_header` varchar(250) collate utf8_unicode_ci NOT NULL,
`story` text collate utf8_unicode_ci,
`sort_order` mediumint(6) NOT NULL,
`zuletzt` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
PRIMARY KEY (`stories_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1 ;

OK, it looks simple.

I want to update only the sort order so I create a form with a submit button, provide a table row with a textfield, bind it to the recordset, apply repeat region according to the recordset: Everything works fine until here.

Applying the multiple update behaviour shows a very strange effect:
Since I do not provide a redirect, I let the field "Go to (optional)" empty and let "pass original querystring" unhooked.

If I update a sort field by entering a different number and press the update button, after the page reloads, the old entry is here again. But looking up the database with phpmyadmin shows: Update with the new entry was succesful!

If I hit the update button again without touching the formfield, the new, updated entry shows up in the form but the database entry has the old value again! If I click the button again, the whole game repeats itself. It toggles the form entry / database entry each time I click the update button.

The best thing is still to come.
This is the start of the WA code:
<?php
// WA DataAssist Multiple Updates
if (isset($_POST["aktualisieren"])) // Trigger
{
if (!session_id()) session_start();
$WA_loopedIDField = array("WADA_RepeatID_stories_id");
$WA_connection = $lil;
$WA_table = "stories";
$WA_redirectURL = "";
$WA_keepQueryString = false;
.....
?>

Now, if I replace the lines

$WA_redirectURL = "";
$WA_keepQueryString = false;

with:

$WA_redirectURL = $_SERVER['PHP_SELF'];
$WA_keepQueryString = true;

The "Update Multiple Records" server behaviour disappears from the Server Behaviours panel but the page works like expected.
No toggle effects anymore.

I am sitting for hours now but don't find a solution...
can someone please tell me whats going on here?

PS.:
Also, one should mention that one has to SELECT the unique key column in the Recordset, otherwise this behaviour does not work at all. I first thought it is not necessary because there is this this "automatic bind" message.

Sign in to reply to this post

Ray BorduinWebAssist

Maybe the order of the server behaviors on the page. Does it help if you put the recordset below the update?

Sign in to reply to this post
Did this help? Tips are appreciated...

office377308

problem solved! & new question ...

yes it does! Thank you Ray!

So what would you suggest? Is it better to create the recordset AFTER the update?
I usually try to avoid a manual copy / paste to and from parts of the code, the more if I don't really understand all the functionality behind it.

And as mentioned before, changing one line in the code manually (the thing with $WA_redirectURL = $_SERVER['PHP_SELF'];) made the multiple update behaviour disappear from the server behaviour's list which means, no more easy updates if some parameters should change.
---------
My next question refers to the multiple delete s.b.
Would it be possible to COMBINE the multiple update with the multiple delete s.b. on the same page?

I tried this but found that the multiple update behaviour had "eaten" my prepared checkbox for the delete behaviour. It changed its name from check2delete to check2delete_<?php echo $RepeatSelectionCounter_1; ?> so that the name did not appear in the list of form elements. (I like the icons!).
So delete did not work, even after removing the "_<?php echo $RepeatSelectionCounter_1; ?>" part.

Sign in to reply to this post

Ray BorduinWebAssist

Ordering of Server behaviors is something DW isn't that great at. The reality is that the recordsets will always be placed above. In some cases you want them above and in some cases you want them below. The only solution is to cut and paste, cutting and pasting recordsets is usually the only thing you need to move, but applying in a different order won't prevent that issue.

Manage Relational Table is basically a combination of multiple insert and update, not sure what you are doing but it may be applicable for you.

If not, I'm sure you could combine them as well, but I'd have to try it once to figure out the particulars and I can't quite diagnose the problem from your description alone.

Sign in to reply to this post
Did this help? Tips are appreciated...

office377308

Use of combined multiple update / multiple delete

I want to manage stories which belong to several categories. On a listing page I display all stories of a certain category ordered by a numeric value, both in German and English. So you don't have more than:
headline, sort order (as a text field -> multiple update - able), a button for editing the content of a story (on a detail page) and a checkbox for multiple deletion.

All headlines are first ordered by language (a numeric value called language_id), then by sort order field, followed by alphabetical sort order in case the user forgot to insert a sort order value.

So, the update multiple applies to the numeric sort order only, on this page. You can change a numeric value in one or several fields, hit update and after the page reloads, you have a fresh sort order. The advantage of this system is, that with one action you can put story #1 to place #2, story#3 to place#1 and story #2 to place#3. Since those entries use this numeric field for sorting, you can see the effect immediately. If there are better suggestions to achieve this, please let me know.
Well, the multiple delete actions are obviously there to delete several stories at once on this page.

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