Get options from mySQL Query - mulitple
2 posts by 2 authors in: Forums > CMS Builder
Last Post: April 20, 2011 (RSS)
By rjbathgate - April 20, 2011
Hello, again.
I have a record which is a list, whose values offered are based on other tables in the CMS.
So, usually use something like:
However, I want to offer records from two tables, i.e. something like:
Putting AND in the middle and reissuing the select query obviously doesn't work, but that's the general idea, so the select box offers:
table_one record 1
table_one record 2
table_two record 1
table_two record 2
Is this at all possible?
Cheers
I have a record which is a list, whose values offered are based on other tables in the CMS.
So, usually use something like:
SELECT num,title
FROM `<?php echo $TABLE_PREFIX ?>study_with_us`
WHERE (education_level = '') AND (parent = '')
However, I want to offer records from two tables, i.e. something like:
SELECT num,title
FROM `<?php echo $TABLE_PREFIX ?>table_one`
WHERE (parent = '')
AND
SELECT num,title
FROM `<?php echo $TABLE_PREFIX ?>table_two`
Putting AND in the middle and reissuing the select query obviously doesn't work, but that's the general idea, so the select box offers:
table_one record 1
table_one record 2
table_two record 1
table_two record 2
Is this at all possible?
Cheers
Re: [rjbathgate] Get options from mySQL Query - mulitple
By Dave - April 20, 2011
Hi Rob,
Here's a few ideas. You could just do two queries and merge both record arrays into one with array_merge:
http://php.net/array_merge
$allRecords = array_merge($tableOneRecords, $tableTwoRecords);
Another option is to use MySQL UNION:
http://dev.mysql.com/doc/refman/5.0/en/union.html
(Try replacing your AND with it)
Hope the helps!
Here's a few ideas. You could just do two queries and merge both record arrays into one with array_merge:
http://php.net/array_merge
$allRecords = array_merge($tableOneRecords, $tableTwoRecords);
Another option is to use MySQL UNION:
http://dev.mysql.com/doc/refman/5.0/en/union.html
(Try replacing your AND with it)
Hope the helps!
Dave Edis - Senior Developer
interactivetools.com
interactivetools.com