This topic is locked

Select multiple values from checkboxes

2/22/2015 10:53:31 AM
PHPRunner General questions
K
kdgsv author

Hi,
I´m using the following code for "Select multiple values from checkboxes or a list field and have them appear as individual database entries"

PHPRunner 8.0 latest build



global $conn;

if ($values["model_id"])

{
$arr = explode(",",$values['model_id']);

// 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 tbl_trans(geraete_id,model_id,trans_ww_product_key) values ('".$values["geraete_id"]."','".$arr[$i]."','".$values["trans_ww_product_key"]."')";
db_exec($strInsert,$conn);

//echo($strInsert);

}

header("Location: cv_parts_by_unit_list.php");

exit();

}


It works fine as long I´m selecting max. 2 entrys on the listbox for the table I want to update.

If i select more than 2 it does not update my table and also not redirect.
Is there maybe a bug?
Thx.
Matthias

Admin 2/22/2015

You need to troubleshoot this code printing SQL queries. Comment out db_exec($strInsert,$conn); line and uncomment the line that prints SQL queries. This can shed more light on what is happening there.

K
kdgsv author 2/22/2015



You need to troubleshoot this code printing SQL queries. Comment out db_exec($strInsert,$conn); line and uncomment the line that prints SQL queries. This can shed more light on what is happening there.


Thank you Sergey,
I´ve done like you recommend.
If I select two entries from the list the following is shown:

insert into tbl_trans(geraete_id,model_id,trans_ww_product_key) values ('67','142','50066666-LSB')insert into tbl_trans(geraete_id,model_id,trans_ww_product_key) values ('67','140','50066666-LSB')


If I select three entries nothing is shown.
Regards
Matthias

Admin 2/22/2015

No sure what else it might be, not enough info. It looks like error is happening before SQL query part if you select three entries and you need to add more debug output to see what value is passed to this function, what is the content of $arr array etc.
If you have a valid support contract post your application to Demo Account and open a ticket at http://support.xlinesoft.com sending your Demo Account URL. 'Demo Account' button can be found on the last screen in the program.

K
kdgsv author 3/10/2015



No sure what else it might be, not enough info. It looks like error is happening before SQL query part if you select three entries and you need to add more debug output to see what value is passed to this function, what is the content of $arr array etc.
If you have a valid support contract post your application to Demo Account and open a ticket at http://support.xlinesoft.com sending your Demo Account URL. 'Demo Account' button can be found on the last screen in the program.


Hallo Sergey,
Thank you.
I´ve used the code mentioned above with PHPRunner 6.2 and it was working fine.

Now with 8.0 it doesn`t.
Was there a minor in 8.0 change which could cause this problem?
Regards

Matthias

Admin 3/10/2015

I cannot provide any meaningful advice until I can reproduce this issue on Demo Account or on some other machine. It just doesn't make any sense.

lefty 3/11/2015



I cannot provide any meaningful advice until I can reproduce this issue on Demo Account or on some other machine. It just doesn't make any sense.



Try using PHPrunner built in Dal Method
Do If ($values["model_id"]){

if ($abort_if_block) break;
global $dal;

$tbltlb_trans = $dal->Table("tbl_trans");
$tbltlb_trans ->Param["geraete_id,model_id"]=$values["YOUR Parameters Here"];
$tbltlb_trans ->Param ["model_id,trans_ww_product_key"]=$values["YOUR next Parameter Here"];
$tbltlb_trans ->Value["Values field here "]="Your values here";

$tbltlb_trans ->Value["Values field here "]="Your values here";

$tbltlb_trans ->Value["Values field here "]="Your values here";
$tbltlb_trans ->Add();
} While (false);
{

header("Location: cv_parts_by_unit_list.php");

exit();

}
This will go through any data for each item checked ; you may need to add a custom qauery to get to this point in conditional staement above