close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Select which records to Multiple Update

Thread began 6/29/2010 5:19 am by phebberd116714 | Last modified 7/26/2010 3:16 pm by Eric Mittman | 1380 views | 5 replies |

phebberd116714

Select which records to Multiple Update

Is there a way to select which records I want to update, maybe with a check box?

I have the Multiple update working by using a test link to a multiple update page. My problem is that all the records in the database are loaded into the page. So I have to read every one to find the ones I want to update.

Ideally, I would like just to see the records I want to update.

Is it possible with DataAssist?

Sign in to reply to this post

Eric Mittman

The multiple update server behavior will allow you to update more than a single record, it is based on a recordset that you have on the page. One way that I could think of to do this would be to use the DataAssist Search server behavior to limit the records to update. You could do this by having a page that has all of the records listed, then have a checkbox next to them like you mentioned. You would want to set the value of the checkbox to be the id of the record and make sure to add in brackets after the name of the checkbox.

This page would post to your multiple update page. You would apply the DataAssist Search server behavior to the multiple update page and specify the search criteria as a list type that looks at the id column. This way when you post the id's from the checkboxes to this page the recordset will only contain the records of the id's you passed.

You can then make the updates to these records and click on your update button to commit the changes. This is just one approach to this with DataAssist. One of the best things about using the WebAssist tools is that you can combine the server behaviors to create the experience that you would like. While this specific setup is not a single supported feature of DataAssist I can help you out if you have any trouble with the different parts of this. Please post back with any questions that you have about this.

Sign in to reply to this post

phebberd116714

Not quite understanding the process

Hi Eric,
Thanks for the reply. I'm not understanding the process so the search isn't working. All the record still show up.
This is what I have done so far –

RESULTS page:
I added the check box to each item (am not sure what you meant by add in brackets after the name of the checkbox).
Here is the code for the checkbox –

<input name="product_id" type="checkbox" id="product_id" value="<?php echo $row_WADAwProd_Bread['product_id']; ?>" />

At the bottom of the list is a text link that goes to the multiple update page –

<a href="wBread_updateMulti.php?product_id=<?php echo((isset($_POST["product_id"]))?$_POST["product_id"]:"") ?>">Update Multiple Records</a>

Not sure if I need the parameters!

MULTIPLE UPDATE Page:
This is where I am not understanding the search behaviour.
I added the following using the DatataAssist Search behaviour. It is at the top before the update code –

<?php
//WA Database Search (Copyright 2005, WebAssist.com)
//Recordset: rsProdBread;
//Searchpage: ;
//Form: ;
$WADbSearch1_DefaultWhere = "";
if (!session_id()) session_start();
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$WADbSearch1 = new FilterDef;
$WADbSearch1->initializeQueryBuilder("MYSQL","1");
//keyword array declarations

//comparison list additions
$WADbSearch1->addComparisonFromList("product_id","".$row_rsProdBread['product_id'] ."","AND","=",0);

//save the query in a session variable
if (1 == 1) {
$_SESSION["WADbSearch1_wBread_updateMulti"]=$WADbSearch1->whereClause;
}
}
else {
$WADbSearch1 = new FilterDef;
$WADbSearch1->initializeQueryBuilder("MYSQL","1");
//get the filter definition from a session variable
if (1 == 1) {
if (isset($_SESSION["WADbSearch1_wBread_updateMulti"]) && $_SESSION["WADbSearch1_wBread_updateMulti"] != "") {
$WADbSearch1->whereClause = $_SESSION["WADbSearch1_wBread_updateMulti"];
}
else {
$WADbSearch1->whereClause = $WADbSearch1_DefaultWhere;
}
}
else {
$WADbSearch1->whereClause = $WADbSearch1_DefaultWhere;
}
}
$WADbSearch1->whereClause = str_replace("\\''", "''", $WADbSearch1->whereClause);
$WADbSearch1whereClause = '';
?>


Do you need any more information? Or can you see where I have made errors.

Regards, Peter

Sign in to reply to this post

Eric Mittman

Even though you are trying to perform an update on the records you can think of your multiupdate page like a results page. So the idea is to get it to limit the records that are shown on this update page to be only the records to update.

On the page with the checkboxes you need to add in the brackets after the name like this:

<input name="product_id[]" type="checkbox" id="product_id" value="<?php echo $row_WADAwProd_Bread['product_id']; ?>" />

Now on the page that you have added the DataAssist Search server behavior to you will need to update it to work with this form element and specify the type of search as a list type. When the form is submitted to this page it should only contain records for the items that you selected.

Sign in to reply to this post

phebberd116714

Search for marked items not working

Hi Eric,

Thanks, for the reply.
I was making some dumb errors in that I put the dataAssist search on the Multiple Update page instead of the results page. DUH!

So what I did was wrap the whole of the results table in a form and added a Button to go to the update page. The form is set to "get".

On the Multiiple Update page I set the recordset to filter by the record id as a form variable (probably wrong on my part).

On testing to select just 2 of the items I get no results and this is what is showing as the url:

wBread_updateMulti.php?product_id%5B%5D=1001&product_id%5B%5D=1002&UpdateMultiple=Update+Multiple+Records

wBread_updateMulti.php?product_id%5B%5D=1001&product_id%5B%5D=1002&UpdateMultiple=Update+Multiple+Records

So I have obviously made some errors.

Attached are the 2 pages in question. Can you please take a look to see what I have done wrong. wBread_ResultsSearchUpdate.php is the main page with the check boxes, wBread_updateMulti.php is the results/update page.

Peter

Attached Files
wBread_ResultsSearchUpdate.php.zip
wBread_updateMulti.php.zip
Sign in to reply to this post

Eric Mittman

To get the page to update the multiple records that you would like to update you will need to have a recordset that lists all of the records with the checkboxes next to them. This page will then post to the multiple update page that has the DataAssist Search server behavior on it. The recordset that you have on this page will be filtered by the DataAssist Search server behavior based on the records that you have selected. This way when you perform the multiple update you can use this DataAssist Search filtered recordset to ensure that only the records you selected are updated.

Currently you have the multiple update page and the DataAssist Search server behavior on two pages. They should be on the same page. The first page in this process should only be listing all of the records with the checkbox next to them. You would then check what records to update and click on the button to post the information to your multi update page. The DataAssist Search server behavior will filter only the selected records for the recordset on this page.

You can make the page that has all of the records showing first and add in the checkboxes and have this post to the next page in the set. Before you add the multiple update to this page just add the recordset and the DataAssist Search server behavior. Test it out by checking selected records then going to this page to see the values from the recordset. You should only ever see the records that you selected on the first page. When you have it working like this you will be ready to add in the multiple update server behavior.

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