This topic is locked

Updating multiple records

3/24/2009 3:15:47 PM
PHPRunner General questions
hichem author

How can I update several records in my list when I tick a number of records and then select the multi Edit button.

Each of the records has a field (status) with a drop down list where I want to set 'closed' for many records at the same time.

Currently when checking many records then selecting 'Edit selected' I will still have to select the option for each record separately.

Is there a way to set in my case status = closed (from teh drop down available) for all the selected records?

Can I use events and how please?

Many thanks in advance for your help

Hich

J
Jane 3/25/2009

Hi,
unfortynately there is no easy way to update all records in the same time.

As workaround you can add new button "Close status", select records on the list page and update it with Close status.

Here are some tips:

  1. proceed to the Visual Editor tab
  2. turn on HTML mode, find this line:
    {BEGIN delete_link}


and add following code just before:

<A onclick="frmAdmin.a.value='update'; frmAdmin.submit(); return false;" href="#">update</A>


And add some code to the BeforeDelete event:

//delete records

if(@$_POST["a"]=="delete")

return true;
//update records

if(@$_POST["a"]=="update")

{

//update your records here

}

return false;

hichem author 3/27/2009

Hi,

unfortynately there is no easy way to update all records in the same time.

As workaround you can add new button "Close status", select records on the list page and update it with Close status.

Here are some tips:

  1. proceed to the Visual Editor tab
  2. turn on HTML mode, find this line:
    and add following code just before:
    And add some code to the BeforeDelete event:


Many thanks Jane, as always brilliant idea.

I was wondering if you would be able to help with the following extended challenge:

Is it possible to have a drop down list for the "Update All"button? that way users can select the same (even hardcoded) values as in each drop down list for each record and update all selected records.

The advantage with this is not to be limited to only 1 status. Is it possible to enhance your suggestion with a drop down list to realize this?

Especially for big tables, bulk changes are very useful so may be a built in solution can be considered for future releases as well.
thanks again in advance Jane.

Hich

J
Jane 3/27/2009

Hi,
just create simple <select> control and use different parameters for each <option> tag:

onclick="frmAdmin.a.value='update1'; frmAdmin.submit(); return false;"

onclick="frmAdmin.a.value='update2'; frmAdmin.submit(); return false;"