Please enable JavaScript to view this site.

Navigation: Advanced topics > Events > Sample events > Database

PHPrunner32x32     PHPRunner manual

Select multiple values from checkboxes/list field to make them appear as individual database entries

Scroll Prev Next More


To select multiple values from checkboxes or a list field and have them appear as individual database entries, use the following code in the Add page: Before Record Added event.


Note: Change red values to match your project.


if ($values["fieldname"])
$arr = explode(",",$values["fieldname"]);
// This is the name of the multi check box or
// list select field, its value becomes $arr
for ($i=0;$i<count($arr);$i++)
$strInsert = "insert into TableName (field) values ('".$arr[$i]."')";
// add more fields from the add page to be inserted into database
header("Location: MyPage_list.php");
// Exit and Redirect to the list page after updating database

See also:

JavaScript API:getSelectedRecordKeys()

Database API: DB::Exec

Redirect to another page


Created with Help+Manual 7 and styled with Premium Pack Version 3 © by EC Software