Selecting Data from one table for use in another table
2 posts by 2 authors in: Forums > CMS Builder
Last Post: April 4, 2013 (RSS)
By (Deleted User) - April 4, 2013
In an admin only section I would like to add packages and sites
for example:
Package A would only have a option of displaying on Domain A
Package B would have an option of displaying on Domain A and Domain B
Package C would have an option of displaying on Domain C and Domain D
I have created 3 tables package_type, package_level, package_websites (all these work fine)
In another table I'm trying to pull in a list of the websites based on the package subscribed to using this:
SELECT package_websites FROM cms_package_websites WHERE package_type='<?php echo $ESCAPED_FILTER_VALUE ?>' refresh when package_type changes
Any help would be appreciated
By gregThomas - April 4, 2013
Hi,
I think you're going about this the right way, is there a particular problem that you're coming across?
The only change I think you might need to make is to your select statement:
SELECT package_websites FROM cms_package_websites WHERE package_type='<?php echo $ESCAPED_FILTER_VALUE ?>' refresh when package_type changes
The select part of your statement should contain the two fields that you want to be the value and label for the drop down, at the moment if looks as if you're using a table name. This post has a good example of how to use the system:
http://www.interactivetools.com/forum/forum-posts.php?postNum=2218572#post2218572
Your select statement should probably look something like this:
SELECT value_field, label_field FROM cms_package_websites WHERE package_type='<?php echo $ESCAPED_FILTER_VALUE ?>' refresh when package_type changes
You would need to change value_field and label_field to the names of two fields from the cms_package_websites section you want to be your values and labels for the field. Finally, the field in your where statement should be the list field that stores the package_type values.
Thanks!
Greg
PHP Programmer - interactivetools.com