Display a list by keyword
3 posts by 2 authors in: Forums > CMS Builder
Last Post: July 13, 2010 (RSS)
By depdesign - July 13, 2010
I'm trying to display a record from a table (table name is "Loan") on a page if it contains a keyword from a pulldown field named "Items". For example: The "Items" pulldown contains the following list options:
> red house
> red car
> blue house
> blue car
On the page I am trying this but it does not display anything:
<?php if (strpos($Loan['Items'], 'red')): ?>
Display this area
<?php endif ?>
The above only works if I enter the full name like this example
<?php if (strpos($Loan['Items'], 'red house')): ?>
Display this area
<?php endif ?>
My objective is to display anything from a pulldown list that contains a keyword "red".
Any suggestions?
> red house
> red car
> blue house
> blue car
On the page I am trying this but it does not display anything:
<?php if (strpos($Loan['Items'], 'red')): ?>
Display this area
<?php endif ?>
The above only works if I enter the full name like this example
<?php if (strpos($Loan['Items'], 'red house')): ?>
Display this area
<?php endif ?>
My objective is to display anything from a pulldown list that contains a keyword "red".
Any suggestions?
Dan Perez
Re: [depdesign] Display a list by keyword
By Jason - July 13, 2010
Hi,
What you can do is only select the records in loans that have red it the items field, this way you don't have to worry about checking them after you've gotten your records. You could try something that could look like this:
Try something like this. If you run into any trouble, let me know and attach the .php file you're working with so I can take a closer look at what's going on.
Hope this helps.
What you can do is only select the records in loans that have red it the items field, this way you don't have to worry about checking them after you've gotten your records. You could try something that could look like this:
list($loanRecords,$loanMetaData) = getRecords(array(
'tableName' => 'loan',
'where' => "items LIKE '%red%'",
));
Try something like this. If you run into any trouble, let me know and attach the .php file you're working with so I can take a closer look at what's going on.
Hope this helps.
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com
Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/
Jason Sauchuk - Project Manager
interactivetools.com
Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/
Re: [Jason] Display a list by keyword
By depdesign - July 13, 2010
Exactly what i was looking for. Your good!
Dan Perez