[SOLVED] Select multiple rows and perform operations

Talk about implementation of multirow operations

Moderators: ne_moj, zewa

asherw
Junior
Junior
Posts: 20
Joined: Mar 28th, '09, 17:10

[SOLVED] Select multiple rows and perform operations

Postby asherw » Mar 28th, '09, 17:17

Hi,

I need to add a checkbox to every row (for multiple row selection) and have a button. When a user clicks the button, I need to save the selected rows into a different database. Basically I need to transfer data from one database to another database (but allowing the user to select the data). How can I do that and is it possible?

Thanks in advance,
Asher
Last edited by asherw on Mar 31st, '09, 15:54, edited 1 time in total.

asherw
Junior
Junior
Posts: 20
Joined: Mar 28th, '09, 17:10

Re: Select multiple rows and perform operations

Postby asherw » Mar 28th, '09, 17:20

Sorry for double posts. But I also need to know how to access the selected row individually and remove it from the selected grid (on the screen, not the database) and copy to the other grid (and the database).

I am able to add a checkbox to every row by using

$multirow_option = true;
$dgrid->AllowMultirowOperations($multirow_option);
$multirow_operations = array(
"delete" => array("view"=>false),
"details" => array("view"=>false),
"transfer" => array("view"=>true, "flag_name"=>"sel_name", "flag_value"=>"sel_value", "tooltip"=>"Transfer selected", "image"=>"update.gif")
);
$dgrid->SetMultirowOperations($multirow_operations);

but still not sure how to access individual row (selected rows).

Thanks again,
Asher

metier
Expert
Expert
Posts: 56
Joined: Jan 24th, '09, 03:14

Re: Select multiple rows and perform operations

Postby metier » Mar 29th, '09, 16:14

Take a look at this thread from the old forum:

http://www.phpbb88.com/phpbuilder/viewt ... phpbuilder

asherw
Junior
Junior
Posts: 20
Joined: Mar 28th, '09, 17:10

Re: Select multiple rows and perform operations

Postby asherw » Mar 30th, '09, 15:14

Thanks.

asherw
Junior
Junior
Posts: 20
Joined: Mar 28th, '09, 17:10

Re: Select multiple rows and perform operations

Postby asherw » Mar 31st, '09, 02:52

Well, for some reason I have a blank rids array. Here is the code:

Code: Select all

$multirow_option = true;
$dgrid->AllowMultirowOperations($multirow_option);
$multirow_operations = array(
"delete" => array("view"=>false),
"details" => array("view"=>false),
"transfer" => array("view"=>true, "flag_name"=>"transfer", "flag_value"=>"transfer", "tooltip"=>"Transfer selected", "image"=>"update.gif")
);
$dgrid->SetMultirowOperations($multirow_operations);


After $dgrid->Bind(); and ob_end_flush(); I added the following code:

Code: Select all

if(isset($_GET[$unique_prefix.'mode']) && ($_GET[$unique_prefix.'mode'] == "transfer") )
{
  // PREPARE THE IDs selected FOR A QUERY
   $rid = explode("-", $_GET['f_rid']);
   $i_rid = count($rid);
   $idstatement = array();
   for ($i=0; $i < $i_rid; $i++) {
      $idstatement[] = "'".$rid[$i]."'";
   }
   $rid = implode("," , $idstatement);

    // do selected rows

   $sql = "INSERT INTO " . $tablename . " (prod_id, prod_name, prod_class, prod_size)
      SELECT prod_id, prod_name, prod_class, prod_size
      FROM productlist WHERE id IN (".$rid.")";
   mysql_query($sql);
    // refresh your page
    echo "<meta>";
}


When I print $rid, it's blank. For example, if I selected 3 items it prints (,,) if I selected 2 item it prints (,).

What could be wrong? I thought everyone uses the same code... :(

Asher

asherw
Junior
Junior
Posts: 20
Joined: Mar 28th, '09, 17:10

Re: Select multiple rows and perform operations

Postby asherw » Mar 31st, '09, 15:54

Got it to work, I forgot to include id during select. Thank you guys!

devluis
Newbie
Newbie
Posts: 2
Joined: Jun 18th, '13, 06:25

Re: [SOLVED] Select multiple rows and perform operations

Postby devluis » Jun 18th, '13, 06:38

I'm working with the APPHP datagrid version 7.7.7 and i solved with the following code:

Code: Select all

if(isset($_REQUEST[$unique_prefix.'mode']) && ($_REQUEST[$unique_prefix.'mode'] == "transfer")){
  $rid = explode("-", $_REQUEST['f_rid']);
  $i_rid = count($rid);
  $idstatement = array();
  for ($i=0; $i < $i_rid; $i++) {
      $idstatement[] = "'".$rid[$i]."'";
   }
   $rid = implode("," , $idstatement);

   require_once 'mydbconection.php';

    // do selected rows
   $sql = "UPDATE projects SET status = 'Finish' WHERE id_project IN ($rid) ";
   mysql_query($sql);
    // refresh your page
    echo "<meta http-equiv='refresh' content='0;url=http://misite.com/myselfgridpage.php' />";
}


Return to “Settings: multirow operations”