This topic is locked

How do I account for the check box in list pages?

11/25/2010 3:51:52 PM
PHPRunner General questions
K
karmacomposer author

I added a button to the list page. Admin can choose people via the check box. When pressed, the button needs to change the GroupID from 1 to 6 for all checked records. Here is the code:
// Put your code here.

//if ($_SESSION['GroupID'] == 1)

$sql="SELECT UserID, GroupID FROM UserValidation ORDER by UserID DESC LIMIT 1";

$rs=CustomQuery($sql);

$RecData=db_fetch_array($rs);
global $conn,$strUserValidation;

$strSQLSave = "UPDATE UserValidation SET ('GroupID') values (";

$strSQLSave .= "6";

$strSQLSave .= ")";

db_exec($strSQLSave,$conn);
However, how do I account for the checkboxes in the list page? As I said before, people click the check boxes and then the code above needs to change them all. How do I do this? Do I use the WHERE command? If so, what is the variable name for the checkboxes? This is the HTML for the checkbox: <INPUT type=checkbox {$checkbox_attrs}> Is this the variable? How would I format this in the code above?
Mike

kujox 11/26/2010

I've accounted for them by adding a button on the list page and using the following code, ID is the primary key in my table



### this goes in the OnServer function ###

$result['txt'] = "";

foreach($keys AS $value) {

$result['txt'] .= update_record($value['id']);# this is a function i've wrote, included in after app initialised but you can put any code here.

$result['txt'] .= "Record " . $value['id'] . " updated
";

}
### this is in the OnAfter function just for the updated message ###

var message = result["txt"] + "
Completed";

ctrl.setMessage(message);
K
karmacomposer author 11/26/2010

I am not sure I get how to apply this. Thank you for the advice, however.
Mike

Sergey Kornilov admin 11/26/2010

I recommend to check this article:

http://xlinesoft.com/phprunner/docs/update_multiple_records.htm
It explains how to use IDs of selected records to build SQL statements.