SELECT, query

3 posts by 2 authors in: Forums > CMS Builder
Last Post: January 18, 2012   (RSS)

Re: [rez] SELECT, query

By rez - January 17, 2012

SELECT cms_vendor_services.title, cms_vendors.company, cms_vendors.rep FROM cms_vendors INNER JOIN cms_vendor_services ON cms_vendors.services=cms_vendor_services.num",


thats working. these are two editors / tables, so how do i use cmsb to now replace this code and give the exact output which is stored in a variable and used in a script i have acquired?

hope that makes sense. thanks for your support.

Re: [rez] SELECT, query

By Jason - January 18, 2012

Hi,

The easiest way to do this is to create an array that has the service's record num as an index and the services title as a value. You can then output a service title by using the number returned by your query as an index.

This example assumes that you are using CMS Builder version 2.08 or higher:

$allServices = mysql_select("vendor_services");
$serviceNumToTitle = array_combine(array_pluck($allServices, 'num'), array_pluck($allServices, 'title'));


You should then be able to output a service's title like this:

<?php echo $servicesNumToTitle[$Driver['service']]; ?>

Hope this helps
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/