Please enable JavaScript to view this site.

Navigation: Advanced topics > Events > Sample events > Database

PHPrunner32x32     PHPRunner manual

Update multiple records on the List page

Scroll Prev Next More


To update multiple records on the List page at the same time, you can create a new Update selected button, then choose records on the List page and click the Update selected button.


Note: Change red values to match your project.


1. Proceed to the Page Designer screen.


2. Create the Update selected custom button and add the following code to the Server tab:


global $dal;
while ( $data = $button->getNextSelectedRecord() ) {
  // set ReportsTo field to 'Bob Smith'
  $sql = "Update employees set ReportsTo='Bob Smith' where KeyField=".$data["KeyField"];
$result["txt"] = "Records were updated.";


and to the Client After tab:


var message = result["txt"];


The Client Before tab should be blank (delete sample code there if you have any).

See also:

Data Access Layer

Database API

Tri-part events

Button object: getNextSelectedRecord()

About SQLQuery class

AJAX helper object: setMessage()


Created with Help+Manual 7 and styled with Premium Pack Version 3 © by EC Software