A while back diafol helped me get a searching script working. It works very well the only problem I am having now is getting it to return the searched values. Here's some context to walk you through the process.
I have a search page, image attached as help1.png, which I am trying to find a record that has the service county as "Johnson" and the License/Certificate as "Certified Social Worker" (NOTE both are arbitrary values that I picked because I specifically made a record to contain both values also see help2.png) the code can be found HERE please also note that the case statement is not done yet, only look at case 2 for the license2 field. The old code was everything but the case statements using the code in the default area as it's primary code. This worked and would return if I was searching "Certified Social Worker" but there was one problem which is what I am trying to fix. There are 5 fields (license1, license2, license3, license4, license5) which are all the same field but are only there in case someone has more than one license they can use the second field to specify and the 3rd if they have a 3rd and so on. The searching becomes an issue when I am looking for someone who has multiple fields and has listed the field I am searching for in a different license spot. Let's say I am searching Certified Social Worker and I put that in the License/Certificate 1 search area but there is someone who is also a registered nurse and put that before the Certified Social worker and put the Certified Social Worker in the License 2 spot. I wouldn't get back that record because I searched for Certified Social Worker in the License 1 spot. The case statements are my way of making it so that if they enter some value for a license field it will search not only the license field that the value was entered into but also the other 4. From what I see the stmtstring looks fine, I included it at the bottom, and the whereclause and bindarray also look fine, also included at the bottom. I am not getting an error I am just getting no result.
stmtString:
SELECT * FROM VolunDB WHERE `johnson` = :johnson AND `license1` = :license21 AND `license2` = :license22 AND `license3` = :license23 AND `license4` = :license24 AND `license5` = :license25
WhereClause and BindArray using Var_Dump (in that order)
array(6) {
[0]=>;
string(24) "`johnson` = :johnson"
[1]=>;
string(23) "`license1` = :license21"
[2]=>;
string(23) "`license2` = :license22"
[3]=>;
string(23) "`license3` = :license23"
[4]=>;
string(23) "`license4` = :license24"
[5]=>;
string(23) "`license5` = :license25"
}
array(6) {
[":johnson"]=>;
string(9) "Johnson"
[":license21"]=>;
string(23) "Certified Social Worker"
[":license22"]=>;
string(23) "Certified Social Worker"
[":license23"]=>;
string(23) "Certified Social Worker"
[":license24"]=>;
string(23) "Certified Social Worker"
[":license25"]=>;
string(23) "Certified Social Worker"
}
I also attached an image using Inspect element to show that the values are being sent to the page that is named help3 and help4 is just a small picture of the Value in the Database.
Please let me know if there is anything I am not making clear. There is a lot of information to type and I am not sure if I am missing something you want to see.
help5.png is a diagram that sort of shows what needs to happen.
Basic overview:
Need:
Search multiple database columns with 1 dropdown field.
Example:
Field1 = "dog"
Column1 = "bird"
Column2 = "cat"
Column3 = "dog"
Run search:
OUTPUT: 'Found Match' IF Column1 OR Column2 OR Column3 CONTAINS Field1
bird =/= dog
cat =/= dog
dog = dog
'Found Match'