This topic is locked
[SOLVED]

 Button - GetNextSelectedRecord

9/19/2018 2:23:46 PM
PHPRunner General questions
A
Andrew S author

I've searched the forum to no avail regarding my issue. Hopefully someone can point me in the right direction.
PHP Runner 9.8 (Have 10 but not yet using)
I have a inventory table with just under 40,000 records. I display 100 records per page and all fields are searchable (only 5 fields in the table!).
I have setup a Make Inquiry Button and used the following code from the manual which works when all selected records are on the first page. If user selects some records from page 1 and then goes to page 2 or more and selects more records (which will often happen). Only records selected on page 1 get emailed when Make Inquiry button clicked.
Is this a bug or is there something I am missing.
Code for Button - Server
$email_msg = "";
//$email_msg.= "List of records selected";
$i=1;
while($data = $button->getNextSelectedRecord())
{
$email_msg.= "Number: ".($i++)."\r\n";
$email_msg.= "Case Number: ".$data["Case_Number"]."\r\n";
$email_msg.= "Description: ".$data["Description"]."\r\n";

$email_msg.= "\r\n";

//$email_msg.= "Database record ID: ".$data["ID"]."\r\n";
$email_msg.= "\r\n";
}
//send email
$email = "**@googlemail.com";
$subject = "List of Interest";
runner_mail(array('to' => $email, 'bcc' => '
@***', 'subject' => $subject, 'body' => $email_msg));

admin 9/19/2018

Record selection only works on a single page. Once you go to another page previous selection is lost.

A
Andrew S author 9/19/2018



Record selection only works on a single page. Once you go to another page previous selection is lost.


Thanks for prompt reply. Is there any work around using additional code to achieve this ? When user searches for a specific item it could well return up to 3000 records of which only a few would be relevant. If I can help it I don't want to increase number of records per page as this will have resource and response issues.

admin 9/20/2018

This can be done but more work is required. What you looking for is a sort of a shopping cart.
You will need to save checkbox selection in session array. Every time user selects a checkbox you add a new item with record ID to that array. Every time checkbox is cleared you remove that item.
When they finally click that button instead of using while($data = $button->getNextSelectedRecord()) you loop through this session array. The at the end you will need to clear that array. The rest of code will stay the same.
I would estimate this as five hours of work for an experienced developer.

A
Andrew S author 9/20/2018

Thanks again Sergey. It crossed my mind that Session was required but having never used Session Arrays I will have to do some reading and trying. In the meantime I have informed the user it will have to be on 'wish list' rather than delay live project.
Keep up the good work.

admin 9/20/2018