We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 16892
    • 107 Posts
    how do i query another mysql db and display the results? is it done in a snippet?

    i need to query a table and return a list of locations, instructors and prices. i want to set these queries up as snippets/chunks so that they can be reused in templates. i’ve seen in one topic where php can’t be used in snippets, but it’s not listed in the documentation one way or the other.

    how do i do this?

    legatissima
      • 18397
      • 3,250 Posts
      Yes, you would use a snippet with php code (but no php start end tags [ for example <?php ])
      • There are a number of ways, but I recommend using the DBAPI to create a new connection and use it like so...

        $mydb= new DBAPI();
        $mydb->connect($host='localhost',$dbase='dbname', $uid='dbuser',$pwd='dbpassword');


        ...replacing the parameters appropriately. You can then use the DBAPI as usual.
          • 16892
          • 107 Posts
          excellent. thanks!