This topic is locked
[SOLVED]

 Checkbox List

5/20/2009 6:47:40 AM
PHPRunner General questions
A
acpan author

Hi all,
I just bought the upgrade and like the new 5.1 version features!
I am using the checkbox list and have the following question:
My Look up table for checkbox list:
Table: Category

ID Name

---------------

1 Shopping

2 Business

3 Casual
2. My travel_objective Table:
Table: Travel_Objective

ID Name Category

---------------------------

1 Allen 2,3

2 Jack 2

3 Tom 2
Above means Allen go for Business(2) and Casual(3)

and Jack goes for Business (2) and Tom goes for Business (2).
Now, user Ray filled in the form with checkbox list,

and picked the checkbox list with Shopping(1) and Casual(3)

the table becomes like this:
Table: Travel_Objective

ID Name Category

---------------------------

1 Allen 2,3

2 Jack 2

3 Tom 2

4 Ray 1, 3
Question:
I want a query list of all who go for Shopping(1) and Casual(3).

How should my mySQL syntax be ?
I tried:

select * from Travel_Objective where `list`in (1,3);
Result returned which is not what i want:

4 Ray 1, 3
I want it to be i.e. Both Allen and Ray gone for Shopping and Casual:

1 Allen 2,3

4 Ray 1, 3
Many thanks in advance for the advise
acpan

J
Jane 5/21/2009

Hi,
I suppose SQL should look like:

select * from Travel_Objective where `list`like '%1%' or `list` like '%3%'

N
nwanzeo 8/14/2009

Hi,

I suppose SQL should look like:


Hi Jane,
I have the same problem as above except that i am not able to populate the category field with multiple values from the checkbox.

Thus, if a user select multiple options from the check boxes my database only displays one.
Please how can i insert multiple values from the check boxes into a field (maybe separated by comma)?
Thanks in advance.

N
nwanzeo 8/16/2009



Hi Jane,
I have the same problem as above except that i am not able to populate the category field with multiple values from the checkbox.

Thus, if a user select multiple options from the check boxes my database only displays one.
Please how can i insert multiple values from the check boxes into a field (maybe separated by comma)?
Thanks in advance.


Somebody help please.

I want to be able to insert values from another table into a table using checkboxes.

Everytime i try, only one value is returned or atimes 0

A
acpan author 8/16/2009

Hi,
Go to visual editor,
Set the new field to store the checkbox selection to:

  1. Lookup wizard
  2. Lookup table = your_lookup_table

    link field = your_lookup_table_primary_key

    Select check box list
  3. Try to add or edit.
    Make sure that the field to hold the check box list is character not int.
    hope it helps.

    acp

N
nwanzeo 8/16/2009

Hi,

Go to visual editor,
Set the new field to store the checkbox selection to:

  1. Lookup wizard
  2. Lookup table = your_lookup_table

    link field = your_lookup_table_primary_key

    Select check box list
  3. Try to add or edit.
    Make sure that the field to hold the check box list is character not int.
    hope it helps.

    acp


Hi acpan,
Thanks very much. You solve my problem!

If you don't mind, i need further advice.
My problem really is that i have two tables (members and subgroups).

Members can belong to multiple subgroups (which you earlier post resolved) and a subgroup could have multiple members.
I implemented a master detail relationship for the two table. Now, members are able to select multiple subgroups (as checkbox option).

The issue now is that from the subgroup table, there is no way of knowing who belong to which group as the primary key field in the members table has a list of comma separated values (except where a members belongs to only one subgroup).
Thanks in advance.

J
Jane 8/17/2009

Hi,
unfortunately PHPRunner do not support multiple values in the master-detail relationships.

You can create custom link using custom format on the "View as" settings dialog on the Visual Editor tab. Actual code is dependent on your tables/values.
You can publish your project on Demo Account and open a ticket at http://support.xlinesoft.com sending a URL to your pages along with detailed description of what you want to do and I'll try to help you.

A
acpan author 8/17/2009



Hi acpan,
Thanks very much. You solve my problem!

If you don't mind, i need further advice.
My problem really is that i have two tables (members and subgroups).

Members can belong to multiple subgroups (which you earlier post resolved) and a subgroup could have multiple members.
I implemented a master detail relationship for the two table. Now, members are able to select multiple subgroups (as checkbox option).

The issue now is that from the subgroup table, there is no way of knowing who belong to which group as the primary key field in the members table has a list of comma separated values (except where a members belongs to only one subgroup).
Thanks in advance.


Hi,
In CSV, it's hard to identify the master unless you form all possible SQL

conditions for the Query in events codes. I managed to form a all

conditions SQL as follows:
" subgroup_id like 'x,%' or subgroup_id like '%x,%' OR subgroup_id like ',x'

OR subgroup_id like 'x' OR subgroup_id like '%,x' "
So if data is:
Row 1: "2,3,1"

Row 2: "1,2,3"

Row 3: "3,1,2"

Row 4: "2"

Row 5: "1,3,2"
And if you are interested in ID=2 in the CSV for all rows,

you can apply the SQL conditions will get all rows who has "2":
" subgroup_id like '2,%' or subgroup_id like '%2,%' OR subgroup_id like ',2'

OR subgroup_id like '2' OR subgroup_id like '%,2' "
That will give you all master rows who have "2" in their CSV values.
In events codes, you can do some pre-processing and get to the

above stage.
I am guessing what you need, if the above does not help,

please try Jane's advise.
acpan.

N
nwanzeo 8/17/2009



Hi,
In CSV, it's hard to identify the master unless you form all possible SQL

conditions for the Query in events codes. I managed to form a all

conditions SQL as follows:
" subgroup_id like 'x,%' or subgroup_id like '%x,%' OR subgroup_id like ',x'

OR subgroup_id like 'x' OR subgroup_id like '%,x' "
So if data is:
Row 1: "2,3,1"

Row 2: "1,2,3"

Row 3: "3,1,2"

Row 4: "2"

Row 5: "1,3,2"
And if you are interested in ID=2 in the CSV for all rows,

you can apply the SQL conditions will get all rows who has "2":
" subgroup_id like '2,%' or subgroup_id like '%2,%' OR subgroup_id like ',2'

OR subgroup_id like '2' OR subgroup_id like '%,2' "
That will give you all master rows who have "2" in their CSV values.
In events codes, you can do some pre-processing and get to the

above stage.
I am guessing what you need, if the above does not help,

please try Jane's advise.
acpan.


hi acpan,

I am grateful. Will try your suggestion (you guessed right) and get back.