This topic is locked

Multiselect and inset as individual entries

11/27/2019 6:19:23 PM
PHPRunner General questions
D
david22585 author

https://xlinesoft.com/phprunner/docs/select_multiple_values_to_show_as_database_entries.htm
Using this code, I was wondering if there was a way to use it with a field that's a INT instead of a VARCHAR type? It works if I select 1 or 2 from a multiselect box, but if I select 3 or more, it transmits blank data for some reason. Here is the code I'm using:

if ($values["account_id"])

{

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

$j = count($arr);

for($i = 0; $i < $j ; $i++)

{

$strInsert = "update accounts_data set balance=balance+".$values["debit"]." where id='".$arr[$i]."'";

DB::Query($strInsert);

}


Not quite sure why it would work for 2 if its a INT type for account_id, but not work if there is 3 or more. If I make the field VARCHAR, it works but the issue is that the account_id field in accounts_data is an INT with auto increment for when new accounts are added. So I can't make that a VARCHAR type field. What the code here is doing is reading each account id where it matches "account_id", and updating their balance by adding the new debit charge to it. There isn't new data being added, but rather just updating an existing row.
Or maybe there is a better way to do the loop with each account is that I don't know about?

fhumanes 11/28/2019

Hi:
The field where you are going to indicate that you have to collect the multiple selections must be "varchar". The content will be stored with this format "12,23,43,56,76", where each decimal value will be an ID of the Lookup selection table.
Regards,

Sergey Kornilov admin 11/29/2019

As Fernando says, the field that is setup is Lookup Wizard must be a varchar.