This topic is locked

Code for retrieve checkbox values

12/21/2009 9:32:24 AM
PHPRunner General questions
C
clawes author

Does anyone have code snippet that shows how to store AND retrieve checkbox values?
Thanks,

Conrad

S
Sekaidragon 12/21/2009

Here's an example of what I use in an AfterAdd or AfterEdit Event:



// Get Database Connection...

global $conn;
// Get current Table Name...

$strTableName = substr($_SERVER["SCRIPT_NAME"],strrpos($_SERVER["SCRIPT_NAME"],"/")+1);
// Retrieve Checkbox State from the Form and Store in Active Database...

if($values['checkboxfieldname'] == 1) // The CheckBox is Checked...

{

strSQLUpdate="UPDATE ".$strTableName." SET checkboxfieldname = 1 WHERE ".$where.";";

db_exec($strSQLUpdate,$conn);

// and/or perform some other action...

}

else // The CheckBox is not CheckBox...

{

strSQLUpdate="UPDATE ".$strTableName." SET checkboxfieldname = 0 WHERE ".$where.";";

db_exec($strSQLUpdate,$conn);

// and/or perform some other action...

}
J
Jane 12/22/2009

Hi,
just set up this field as Checkbox on the "View as" settings/"Edit as" settings dialogs on the Visual Editor tab.