This topic is locked
[SOLVED]

 list select field, its value becomes $arr accepting only 2 values

2/4/2018 4:28:54 AM
PHPRunner General questions
R
riajul74 author

list select field, its value becomes $arr accepting only 2 values If I select more then 2 values from the list "emp_number" then it showing Error

<<< Record was NOT added >>>
Column 'emp_number' cannot be null

Back to list




if ($values["emp_number"])

{

$arr = explode(",",$values["emp_number"]);

// 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 hrm_leave_entitlement (emp_number,no_of_days,

days_used,

leave_type_id,

from_date,

to_date,

credited_date,

note,

entitlement_type,

deleted,

created_by_id,

created_by_name

) values ('".$arr[$i]."',

'".$values["no_of_days"]."',

'".$values["days_used"]."',

'".$values["leave_type_id"]."',

'".$values["from_date"]."',

'".$values["to_date"]."',

'".$values["credited_date"]."',

'".$values["note"]."',

'".$values["entitlement_type"]."',

'".$values["deleted"]."',

'".$values["created_by_id"]."',

'".$values["created_by_name"]."')";

// add more fields from the add page to be inserted into database

db_exec($strInsert);

}

// Exit and Redirect to the list page after updating database

exit();

}
// Place event code here.

// Use "Add Action" button to add code snippets.
return true;

;
Sergey Kornilov admin 2/5/2018

What is the data type of 'emp_number' field in the database?

R
riajul74 author 2/6/2018



What is the data type of 'emp_number' field in the database?



emp_number int(7)

Sergey Kornilov admin 2/6/2018

You cannot store multiple selected numbers in a single numeric field. It must be a text field i.e. VARCHAR.