This topic is locked
[SOLVED]

 Copying record to anothe table

9/5/2019 10:57:05 PM
PHPRunner General questions
mic'',) author

Whats wrong with my code im trying copy this to another table i have 2-3 selector row but when click the button, it only copied 1 record only. Any help please?
global $dal;
$tblItems = $dal->Table('transaction_detail');

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

{

$tblItems->Value["TDID"]='TDID'.(date('ymdhis',strtotime('+8 Hours'))+1);

$tblItems->Value['TID']='TRANS'.date('ymdhis',strtotime('+8 Hours'));

$tblItems->Value['BookID']=$data['BookID'];

$tblItems->Value['BookTitle']=$data['Book_Title'];

$tblItems->Value['UserID']=$data['UserID'];

$tblItems->Value['UserName']=$data['UserID'];

$tblItems->Add();

}

Tandy 9/6/2019



Whats wrong with my code im trying copy this to another table i have 2-3 selector row but when click the button, it only copied 1 record only. Any help please?
$tblItems = $dal->Table('transaction_detail');

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

{

$tblItems->Value["TDID"]='TDID'.(date('ymdhis',strtotime('+8 Hours'))+1);

$tblItems->Value['TID']='TRANS'.date('ymdhis',strtotime('+8 Hours'));

$tblItems->Value['BookID']=$data['BookID'];

$tblItems->Value['BookTitle']=$data['Book_Title'];

$tblItems->Value['UserID']=$data['UserID'];

$tblItems->Value['UserName']=$data['UserID'];

$tblItems->Add();

}



Here is mine that works out great. I know yours is a button but I have it in the event after record added
// Insert a new record into truck_maintenance_logs table - Start

$data = array();

$data["truck_id"] = $values["truck_id"];

$data["truck_number"] = $values["truck_number"];

$data["email"] = $values["email"];

$data["service"] = $values["service"];

$data["date"] = $values["date"];

$data["done"] = $values["done"];

$data["intervals"] = $values["intervals"];

$data["next"] = $values["next"];

$data["mileage"] = $values["mileage"];

$data["due"] = $values["due"];

DB::Insert("truck_maintenance_logs", $data );

// Insert a new record into truck_maintenance_logs table - End

Hope that helpsJames

Admin 9/6/2019

This code looks good to me. Check if there are any error behind the scene:

https://xlinesoft.com/phprunner/docs/troubleshooting_custom_buttons.htm
Also make sure that this table has a proper primary key column selected.

mic'',) author 9/6/2019



Here is mine that works out great. I know yours is a button but I have it in the event after record added
// Insert a new record into truck_maintenance_logs table - Start

$data = array();

$data["truck_id"] = $values["truck_id"];

$data["truck_number"] = $values["truck_number"];

$data["email"] = $values["email"];

$data["service"] = $values["service"];

$data["date"] = $values["date"];

$data["done"] = $values["done"];

$data["intervals"] = $values["intervals"];

$data["next"] = $values["next"];

$data["mileage"] = $values["mileage"];

$data["due"] = $values["due"];

DB::Insert("truck_maintenance_logs", $data );

// Insert a new record into truck_maintenance_logs table - End

Hope that helpsJames


Thanks for this but this will works on after record added event only

but mine is I added checkout button, and supposedly all checked row/record will move to the other table called transaction_details
upon clicking checkout button, it only add 1 record only, I can't find what's wrong with the code im using v10.2

Admin 9/7/2019

This code looks good to me. Check if there are any error behind the scene:

https://xlinesoft.com/phprunner/docs/troubleshooting_custom_buttons.htm
Also make sure that this table has a proper primary key column selected.

mic'',) author 9/7/2019

Thank you much problem solved!