close ad
WARNING: Do Not Install the DREAMWEAVER CC 2017 or 2018 Update »
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Search page pulling in incorrect data

Thread began 2/07/2017 11:37 pm by GaryMorris | Last modified 3/01/2017 6:21 pm by Ray Borduin | 788 views | 58 replies |

GaryMorris

Search page pulling in incorrect data

I have a search page that I am working on. See previous post 'Update page to modify database' for basic info. Created back end, works great.
The fields that are having an issue are ones that are using an array. This is probably simple as I see what it is doing.
Will use one specific field. Specialties. They can be numbered from 1 to about 25.
record 1 has 1,3,5 for entries
record 2 has 1, 7, 13 for entries.
When I search for specialty 1 both records come up.
When I search for 7 #2 comes up.
5 #1 comes up
but.... when I search for 13 or 3 I get both. I assume it is because they both have numbers in common. I also assume somewhere there should be something that tells it to use the comma separator to split it up.
Here is the comparison list line from the results page
$WADbSearch1->addComparisonFromEdit("specialtiesID","specialtiesID","AND","Includes",0);
or is the problem on the search page?
Thanks.
Any help would be appreciated.
Gary.

Sign in to reply to this post

Ray BorduinWebAssist

Are the numbers comma separated or comma-space separated? Hopefully it is consistent and then I think I can give you a solution to this problem based on the answer.

Sign in to reply to this post

GaryMorris

There are 3 fields in each record that are those type arrays. They are all comma separated. No spaces.
I assume the fix is to use explode but I just cant quite get it..
Thanks.
Gary.

Sign in to reply to this post

Ray BorduinWebAssist

The solution is to use a comparison list like this:

$WADbSearch1->addComparisonFrom("specialtiesID","". $_GET["specialtiesID"]. ",","OR","Begins With",0);
$WADbSearch1->addComparisonFrom("specialtiesID",",". $_GET["specialtiesID"]. "","OR","Ends With",0);
$WADbSearch1->addComparisonFrom("specialtiesID",",". $_GET["specialtiesID"]. ",","OR","Includes",0);
$WADbSearch1->addComparisonFromEdit("specialtiesID","specialtiesID","OR","=",0);

Another solution that could work is to create a View in your database with something like:

SELECT Column1, Column2, etc, Concat(',',specialtiesID,',') AS specialtiesWrapped FROM Table

Then you would be able to use just this comparison:
$WADbSearch1->addComparisonFrom("specialtiesID",",". $_GET["specialtiesID"]. ",","OR","Includes",0);

You probably don't want to hear this part, but the reality is that you probably shouldn't be storing the values comma separated to begin with. Those should probably be separate rows in a relational table design particularly if you are searching against them. Storing numbers comma separated in a varchar field is not an efficient solution and wouldn't be suggested in the first place.

Sign in to reply to this post

GaryMorris

Thought I replied already to this but its not here so I will repost.

Thanks for the info. Will check it out.. Actually I would like to do it correctly. I have searched around and read a bunch and am getting more confused.
From what you are saying and what I am reading, I need a 3rd table, correct? mainID (the dr) and specialtyID(the specialty). Many to many relationship. Problem I will have is then I will have to change the back end to get them into the database correctly. How do I insert them into the db.
Then on the search end, will the WA extensions do that?

Hopefully this is the correct way to do it.. Would rather get it right from the beginning.
Thanks so much.


Added after trying above.. after adding the
29 $WADbSearch1->addComparisonFrom("specialtiesID","". $_GET["specialtiesID"]. ",","OR","Begins With",0);
30 $WADbSearch1->addComparisonFrom("specialtiesID",",". $_GET["specialtiesID"]. "","OR","Ends With",0);
31 $WADbSearch1->addComparisonFrom("specialtiesID",",". $_GET["specialtiesID"]. ",","OR","Includes",0);
32 $WADbSearch1->addComparisonFromEdit("specialtiesID","specialtiesID","OR","=",0);

I get this:
Fatal error: Call to undefined method FilterDef::addComparisonFrom() in public_html/mdb/results.php on line 29

Sign in to reply to this post

Ray BorduinWebAssist

Sorry I had a typo. It should have been:
29 $WADbSearch1->addComparison("specialtiesID","". $_GET["specialtiesID"]. ",","OR","Begins With",0);
30 $WADbSearch1->addComparison("specialtiesID",",". $_GET["specialtiesID"]. "","OR","Ends With",0);
31 $WADbSearch1->addComparison("specialtiesID",",". $_GET["specialtiesID"]. ",","OR","Includes",0);
32 $WADbSearch1->addComparisonFromEdit("specialtiesID","specialtiesID","OR","=",0);

Sign in to reply to this post

GaryMorris

Great that worked. He needs to show it to someone in a few days so at least it will work.
I will start checking the other out to make the change.

Was I correct with the Many to Many?

Thanks.

Sign in to reply to this post

Ray BorduinWebAssist

I think technically it would be a one to many.

Sign in to reply to this post

Ray BorduinWebAssist

We have extensions to help.

We have an "Insert Multiple Records" server behavior you can use on your insert page to insert the multiple records into the relational table on the insert page.

On the update page you would use our "Manage Relational Table" extension.

Sign in to reply to this post

GaryMorris

ok. If I have a dr ... mainID1 who can have multiple specialties specialtiesID 1,2,23 I could understand that.
but if many other drs can have the same specialtiesID's . Wont that require a separate table to store the data.

dr spec
1 1
1 2
1 23
2 1
2 23 etc
Isnt that a many to many? I cant see how the add page which is setup with a checkbox for each specialty will work with your multiple record insert.. What am I missing?
Thanks.

Sign in to reply to this post
loading

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...