This topic is locked
[SOLVED]

 Add multiple selected rows to another table

10/7/2016 1:34:06 AM
PHPRunner General questions
B
bioman author

Hi,

I am wondering if it is possible to select multiple rows on a list page and then add them all to another table. Currently, I can achieve something similar by exporting the selected rows and then importing the generated CSV file. Is there a way to bypass the middle step so a user can select multiple records and then click a button to copy these records over to another table? The reason I'm asking is I have a quizzing application for teachers in which there is a question bank. I'd like my users to be able to select questions from the questionbank to add into a different table that stores their quiz questions. It is important that my users can copy the questions over to their own area so that they can edit the question without affecting other users. Is this possible? I'm not sure how to determine that records have been selected in the quiz page. I appreciate any insight. Thanks,

Brett

romaldus 10/7/2016



Hi,

I am wondering if it is possible to select multiple rows on a list page and then add them all to another table. Currently, I can achieve something similar by exporting the selected rows and then importing the generated CSV file. Is there a way to bypass the middle step so a user can select multiple records and then click a button to copy these records over to another table? The reason I'm asking is I have a quizzing application for teachers in which there is a question bank. I'd like my users to be able to select questions from the questionbank to add into a different table that stores their quiz questions. It is important that my users can copy the questions over to their own area so that they can edit the question without affecting other users. Is this possible? I'm not sure how to determine that records have been selected in the quiz page. I appreciate any insight. Thanks,

Brett


It's easy in phprunner. Insert custom button in list page and in server tab add your custom code.
https://xlinesoft.com/phprunner/docs/inserting_button.htm

B
bioman author 10/7/2016

Thanks Romaldus,

To clarify, would this be the right way to get all the selected records?
while($record = $button->getNextSelectedRecord())

{

Code for adding records to other table here...

}
Am I on the right track? Thanks,

Brett



It's easy in phprunner. Insert custom button in list page and in server tab add your custom code.
https://xlinesoft.com/phprunner/docs/inserting_button.htm

romaldus 10/7/2016

For example you have two tables:
table1:

field1, field2, field3
table2:

field7, field8, field9
in table1 list page, add a custom button to copy selected record from table1 to table2

  1. Erase all codes in Client Before tab
  2. in server tab, add the following code:

global $dal;

while ( $data = $button->getNextSelectedRecord() )

{

$sql = "INSERT INTO table2 (Field7, Field8, Field9) values ('".$data["Field1"]."', '".$data["Field2"]."', '".$data["Field3"]."')";

CustomQuery($sql);

}

$result["txt"] = "Record Copied Successfully.";


3. on Client after tab, ad the following:



var message = result["txt"];

ctrl.setMessage(message);
B
bioman author 10/8/2016

Thanks Romaldus,

This was very helpful and worked very well. Thank you very much for your help. Have a good night,

Brett



For example you have two tables:
table1:

field1, field2, field3
table2:

field7, field8, field9
in table1 list page, add a custom button to copy selected record from table1 to table2

  1. Erase all codes in Client Before tab
  2. in server tab, add the following code:

global $dal;

while ( $data = $button->getNextSelectedRecord() )

{

$sql = "INSERT INTO table2 (Field7, Field8, Field9) values ('".$data["Field1"]."', '".$data["Field2"]."', '".$data["Field3"]."')";

CustomQuery($sql);

}

$result["txt"] = "Record Copied Successfully.";


3. on Client after tab, ad the following:



var message = result["txt"];

ctrl.setMessage(message);