Selecting individual items from multi item list box
4 posts by 2 authors in: Forums > CMS Builder
Last Post: October 6, 2008 (RSS)
By MisterJim - October 4, 2008
My question is this...
Now that I've got the multi-item drop box created and working, what is the php or mysql code that needs to be used to check for the existance of one or more of the items within the various products so that only those records will be selected? I guess I need something like (X list CONTAINS "xxxxx" OR "yyyyy" OR "zzzzz"). You get the idea.
Also, Dave... I noticed that when I create the items for the multi-list box, they are dropped into the actual mysql with both leading and trailing spaces. This makes it so that if you do a simple query for something that equals something else, the record does not show up. I've had to manually go into the table and remove the extra spaces.
Jim
Websites That Work
Re: [Mr Jim] Selecting individual items from multi item list box
By MisterJim - October 6, 2008
Simply needed to use the LIKE command in the SQL statment that is used to populate the array.
In my case, where I'm looking for items that are for Sale, it was as simple as adding:
'where' => "display_areas LIKE '%Sale%'",
Jim
Websites That Work
Re: [Mr Jim] Selecting individual items from multi item list box
By Dave - October 6, 2008
Multi value fields are stored in the database as tab separated values with a leading and trailing tab. This is so you can search for (tab)your value(tab) and always get an exact match. In mysql that's:
'where' => "display_areas LIKE '%\tSale\t%'",
You can also try url searches like this:
viewer.php?display_areas=Sale
Hope that helps!
interactivetools.com
Re: [Dave] Selecting individual items from multi item list box
By MisterJim - October 6, 2008
Thanks much. That works just fine.
Jim
Websites That Work