Wreckmaster
Posts: 48
|
Posted: 11/11/2012, 11:21 AM |
|
I would like to create a search box with the options (check box's) shown in the attached image .
is this possible in CSS 4 .
|
|
|
bannedone
Posts: 273
|
Posted: 11/11/2012, 12:34 PM |
|
Hi
This certainly is possible to do.
Simply do this in custom code for the BeforeExecuteSelect event
$Component->ds->Where="The SQL Where Clause Based on the selected checkbox or radio button";
_________________
John Real
CodeCharge Studio Support, Training, Consulting, Development, Web based solutions
http://realsites.biz
http://ccselite.com
Other Banned IDs on this Forum. jjrjr1, jjrjr2 |
|
|
Wreckmaster
Posts: 48
|
Posted: 11/11/2012, 1:09 PM |
|
Thank you bannedone
But that's a little over my head
I have four controls
text box = search_me
checkbox = exc
checkbox = str
checkbox = inc
So do I need a separate select statement for search_me to return exact, starts with, or contains
then another select for the BeforeExecuteSelect event to include checkbox's exc, str and inc
thanks in advance
|
|
|
Lucius
Posts: 220
|
Posted: 11/11/2012, 1:51 PM |
|
Full select statement is usually built from these parts in CCS (when you build it with Designer):
SELECT something FROM something......
WHERE.....
ORDER BY
(and optional) LIMIT....
On Before Execute Select you can change SELECT, ORDER BY and WHERE parts, like bannedone mentioned:
$Component->ds->Where= (here you put your WHERE conditions)
$Component->ds->SQL= (here you put your SELECT something FROM something.....)
$Component->ds->Order = (here as you can guess you put ORDER BY part)
So basically with few IFs (depending which radiobutton is checked), you can freely modify your statement. I guess in your example this will be be only the WHERE part.
Please check the CCS help file and topic " DataSource->Where Run-Time Property (PHP)" also see the Examples links in this help page, especially the "Dynamically Modify the WHERE Clause" topic.
|
|
|
Wreckmaster
Posts: 48
|
Posted: 11/11/2012, 2:17 PM |
|
I am having difficulty understanding how to deal with (what seems to me two instructions)
1. I need to select from D=B where text box = "exact" or "starts with" or "contains" .
2. Select check box, "exc" or "str" or "inc" , to effect the above .
Thank you
|
|
|
bannedone
Posts: 273
|
Posted: 11/11/2012, 2:36 PM |
|
Hmmm
Wreckmaster, I do not understand your last post.
Lucius gave you the exact correct details of how to implement what I suggested.
What are you having difficulty with exactly...???
I am also confused on one of your ealier post where you say you have 4 controls on your form.
By my count there are either 2 or 5 depending how you implement your choice option.
I would suggest using Radio Buttons for that choice in which case there will be only 2 controls (excluding the submit button in all cases)
Then all you gotta do is exactly as Lucius outlined for you..
Build your Where statement for the select as required based on the value of your radio button control.
_________________
John Real
CodeCharge Studio Support, Training, Consulting, Development, Web based solutions
http://realsites.biz
http://ccselite.com
Other Banned IDs on this Forum. jjrjr1, jjrjr2 |
|
|
Wreckmaster
Posts: 48
|
Posted: 11/11/2012, 3:32 PM |
|
Thank you bannedone & Lucius
I have played around with it , but I am just not getting it .
I will come back to this tomorrow with a fresh head .
|
|
|
bannedone
Posts: 273
|
Posted: 11/11/2012, 9:58 PM |
|
Wreckmaster
Sometimes that is the best thing to do. LOL
I do that all the time when I have difficulties.. Just going away and come back later helps alot sometimes.
Let us know if you need more help on this...
Have fun
_________________
John Real
CodeCharge Studio Support, Training, Consulting, Development, Web based solutions
http://realsites.biz
http://ccselite.com
Other Banned IDs on this Forum. jjrjr1, jjrjr2 |
|
|
Wreckmaster
Posts: 48
|
Posted: 11/12/2012, 10:52 AM |
|
Hi Lucas I am back for another go .
Seems to me two things need to happen here .
1. Select from data base.
2. Use if statement to take instruction from the radio button .
Do I need three selects and three if statments ? .
If so can you give me an example of how I might code it,
or am I still on the wrong track ?.
Thank you.
|
|
|
MichaelMcDonald
Posts: 640
|
Posted: 11/12/2012, 11:03 AM |
|
Am no expert on this, I only know the direct SQL command stuff, it looks to me like the question being asked is something along the lines of SELECT field FROM table WHERE criteria = something or IS LIKE something or IS LIKE something else, complex sort of query.....
_________________
Central Coast, NSW, Australia.
|
|
|
Lucius
Posts: 220
|
Posted: 11/13/2012, 5:53 AM |
|
Wreckmaster, this is easy ;) Simple example:
radio1, radio2, etc.. are name of your controls, we have BeforeExecuteSelect event, so..
Your select will stay the same if I understand correctly, all you have to do is to create different WHEREs for your options, lets assume that your basic SQL is something like this
SELECT name, number, something, else FROM table WHERE your_condition = something
So this is exact match you search for.
if ($Component->radio1->checked == true) {
//exact match, we do nothing
}
else if ($Component->radio2->checked == true) {
//starts with
$Container->ds->Where = "your_condition LIKE '%".$your_search_variable"'";
}
else if ($Component->radio3->checked == true) {
//contains with
$Container->ds->Where = "your_condition LIKE '%".$your_search_variable."%'";
}
//and so on....
Above is more of pseudocode, so it might not work exactly, but you should get the idea.
|
|
|
Wreckmaster
Posts: 48
|
Posted: 11/13/2012, 6:24 AM |
|
Thank you very much for your time and expertize Lucius .
Now it makes sense to me, it will be a few hours before I can work on it .
I will get back and let you know how I got on .
|
|
|
bannedone
Posts: 273
|
Posted: 11/13/2012, 6:40 AM |
|
To avoid some frustration to you Wreckmaster.
I would like to point out the above code is really for checkboxes.
One problem using checkboxes is that many could be checked at once confusing the if statements in some conditions.
I suggest using a radio button control with the bound and text colomns set appropriately.
Then use Lucius's example simply checking on the value the radio button sends to the search
_________________
John Real
CodeCharge Studio Support, Training, Consulting, Development, Web based solutions
http://realsites.biz
http://ccselite.com
Other Banned IDs on this Forum. jjrjr1, jjrjr2 |
|
|
|