songohan
Posts: 89
|
| Posted: 09/06/2007, 2:13 PM |
|
guess it is more SQL question but since I work in PHP I'll ask here.
I have records in database and each can belong to Group1, Group2 or Group3. Group3 indicates that record belongs to both Group1 and Group2 .
I need to create search where user can choose Group from listbox. If he selects Group1 I should give him records that are Group1 and Group3, if he selects Group2 I should give him records that are Group2 and Group3 and if Group3 is selected I should give him all records.
So, how should one create SQL select?
Many thnx in advance
Andrej
|
 |
 |
klwillis
Posts: 428
|
| Posted: 09/06/2007, 3:10 PM |
|
Logic you can use would be as follows:
$grouptype = CCGetParam("GroupType","Group3"); //assuming Group3 is default.
$sqlquery = "select <field-list> from <table-name>";
if ($grouptype != "Group3")
{
$sql .= " where group = '$grouptype' or group = 'Group3'";
}
Quote songohan:
guess it is more SQL question but since I work in PHP I'll ask here.
I have records in database and each can belong to Group1, Group2 or Group3. Group3 indicates that record belongs to both Group1 and Group2 .
I need to create search where user can choose Group from listbox. If he selects Group1 I should give him records that are Group1 and Group3, if he selects Group2 I should give him records that are Group2 and Group3 and if Group3 is selected I should give him all records.
So, how should one create SQL select?
Many thnx in advance
Andrej
_________________
Kevin Willis, VP/CIO
HealthCare Information Technology Specialist
http://www.nexushealthcare.com
"Fast - Convenient - Quality-Care"
Medical Software Consulting Services
Email : klwillis@nexushealthcare.com
Skype : klwillis2006 |
 |
 |
songohan
Posts: 89
|
| Posted: 09/10/2007, 11:08 PM |
|
Thnx, somehow I did not manage to implement your code. I tried to use this logic in before Select event to modify datasource.SQL but no luck implementing.
And since I have only 3 parameters to choose from I used dirty trick of hard coding them in a listbox and for third one I passed no value which causes grid to select everything. In grid I also hard coded where clause OR group = 'Group3'.
Will have to find way how to implement custom datasource since I had no luck implementing it jet.
Is there some tutorial about referencing components? I did not manage to get it from help file...
Andrej
|
 |
 |
|