I think you should use custom action, which provides an extra link for each record and when you click the link it will submit the record to custom_action event where you can do whatever you want to that record, ie run some querires. You can even use multiple select and sumit multiple records. Read (custom action) in help menu.
But in summary, draw a custom action for each record like
function ListOptions_Rendered() {
//CREATE An action named, process_lead
//check a condition before you draw it for each record
//use $this->field_name->CurrentValue to access the value of the field you want to check with
//if condition is true then draw this button for this record
$opt = &$this->ListOptions->Add("custom_action");//create the list option first
$opt->Header = "Receipts";//add a header for this column
$this->ListOptions->Items["custom_action""]->Body = "<a href=\"#\" onclick=\"return ew_SubmitAction(event, {action: 'my_action', method: 'postback', msg: 'Perform this action?', key: " . $this->KeyToJson() . "});\">Process This</a>";
}
NOTE:This will work by deafult, unless you have a custom list template body, in which case you have to add an extra column and put {{{list_option custom_action}}}.
NOTE:You should see an extra button next to any of the records in that list page. After this then put your implimentation in Row_CustomAction($action, $row)
Then write you code in custom action to tell it what to do after you submit a given record
function Row_CustomAction($action, $row) {
//check th action to process by
if ($action == "my_action") { // Check action name
//access whetver value of that row by using $row["filed_name"]
$id = $row["id"];
//write sql queries to do what you want here
$this->setSuccessMessage("I have processed lead of id=$id");
return TRUE; // Success
}
}