populate list field based on another list field's selection
14 posts by 3 authors in: Forums > CMS Builder
Last Post: May 24, 2009 (RSS)
By ross - May 13, 2009
I am a little lost on this one now. Are you working inside the forloop for your images?
Could you give me a bit more detail? Thanks!
Cheers,
Ross Fairbairn - Consulting
consulting@interactivetools.com
Hire me! Save time by getting our experts to help with your project.
Template changes, advanced features, full integration, whatever you
need. Whether you need one hour or fifty, get it done fast with
Priority Consulting: http://www.interactivetools.com/consulting/
Re: [ross] populate list field based on another list field's selection
By atomicrabbit - May 13, 2009 - edited: May 13, 2009
list($locRecords, $locMetaData) = getRecords(array(
'tableName' => 'locations',
'where' => 'country="whatever"',
));
It will return the fields in the locations table based on the where statement and I'll be able to loop through the images field using $locRecords['image']['isImage'], $locRecords['image']['thumbUrl'], etc variables. BUT since I need to use multiple where statements, I cannot use the above code. As far as I know, it doesn't support multiple where statements -- i.e. "where w=x AND y=z", which is what I need so I'm forced to use a standard MySQL statement to query the database:
$locRecords = mysql_query_fetch_all_assoc("SELECT * FROM cms_locations WHERE country='" . $_REQUEST['c']
. "' AND province_state='" . $_REQUEST['ps'] . "' AND city='" . $_REQUEST['ci'] . "' ORDER BY country, province_state, city");
BUT, using this does not give me the variables such as $locRecords['image']['isImage'] or $locRecords['image']['hasThumbnail'] or $locRecords['image']['thumbUrl'] (as far as I know)... how do I get those variables using a standard MySQL statement as opposed the to first code snippet.
By ross - May 14, 2009
Thanks for those extra details!
The first thing here is that you can actually have a statement like:
list($locRecords, $locMetaData) = getRecords(array(
'tableName' => 'locations',
'where' => "country='whatever' AND var = 1 AND xwz = 'Ross'",
));
I think that will actually get you going. One thing to notice is that when you have a bunch of things in the where clause, it's usually better to have it surrounded in double quotes so that you can use single quotes around strings like country.
Does that make sense? Let me know :).
Cheers,
Ross Fairbairn - Consulting
consulting@interactivetools.com
Hire me! Save time by getting our experts to help with your project.
Template changes, advanced features, full integration, whatever you
need. Whether you need one hour or fifty, get it done fast with
Priority Consulting: http://www.interactivetools.com/consulting/
Re: [ross] populate list field based on another list field's selection
By atomicrabbit - May 24, 2009
it's weird though -- that's the FIRST thing I tried and for whatever reason, it didn't work the first time. [:/]
Anywho, all is well now. Thanks again!