Combining Output from 2 mysql_select Calls?

5 posts by 2 authors in: Forums > CMS Builder
Last Post: August 24, 2016   (RSS)

By Perchpole - August 24, 2016

Hello, All -

Is it possible to combine the output from 2 mysql_select calls?

I am trying to create a drop-down select menu which would allow people to create a link to a page (category) or record. I need to grab the results from both tables and present them as one list.

I can do this in the backend using mySQL.

SELECT CONCAT('./', permalink) AS URL, CONCAT(name,' (Page)') AS LINK from cms_pages
SELECT CONCAT('?rec=', num) AS URL, CONCAT(name,' (Record)') AS LINK from cms_records

However, on a normal page it is proving more troublesome!

Any suggestions?



By Daryl - August 24, 2016

Hi Perch,

What were the problems when you tried to do it on a normal page?


Daryl Maximo
PHP Programmer -

By Daryl - August 24, 2016

Yes, it will be heavy if both tables have lots of records.

It's a bit tricky to sort a combined multi-dimensional array.
So I'd like to suggest to use mysql_select_query() function, for example:

$urlsAndLinks = mysql_select_query("SELECT CONCAT('./', permalink) AS URL, CONCAT(name,' (Page)') AS LINK from {$GLOBALS['TABLE_PREFIX']}pages
                                    SELECT CONCAT('?rec=', num) AS URL, CONCAT(name,' (Record)') AS LINK from {$GLOBALS['TABLE_PREFIX']}records
                                    ORDER BY LINK");

Let me know how it goes.


Daryl Maximo
PHP Programmer -

By Perchpole - August 24, 2016

Ah. You see. A little (intelligent) light in dark places makes all the difference!