CodeCharge Studio
search Register Login  

Visual Web Reporting

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> PHP

 how to select

Print topic Send  topic

Author Message
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
View profile  Send private message
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
View profile  Send private message
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
View profile  Send private message

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

MS Access to Web

Convert MS Access to Web.
Join thousands of Web developers who build Web applications with minimal coding.

CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.