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:
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?
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?