This topic is locked
[SOLVED]

To select multiple values from checkboxes and have them appear as individual entries

11/6/2022 9:30:00 AM
PHPRunner General questions
P
ppradhan@live.com author

for some reason, this code is not working with me. has anyone experience same issue?

Add page: Before Record Added event.

if ($values["unit_id"])
{
$arr = explode(",", $values["unit_id"]);
for ($i=0;$i<count($arr);$i++)
{
$strInsert = "insert into itemsizeunit (itemsize_id, unit_id) values ('".$values["itemsize_id"]."', '".$arr[$i]."')";
db_exec($strInsert);
}
header("Location: itemsizeunit_list.php");
exit();
}

both fields are integer. I hope code works for both integer and varchar.

Please advice.

P
ppradhan@live.com author 11/6/2022

I tested for with multiple selection and found that if I select upto 2 values, it does add 2 entries. But if selection is more than 2, it does not write in the database.
Can anyone please help me fix this issue?

admin 11/6/2022

Lookup wizard field needs to be a varchar field. If it is numeric, PHPRunner will try to convert the enetered value to a number and it will truncate the value, even if you are not saving it in the database.

P
ppradhan@live.com author 11/7/2022

Thank you Admin, it worked like charms after adding an additional field with VARCHAR.