Multiple Fields in CMS Drop Down

5 posts by 3 authors in: Forums > CMS Builder
Last Post: June 1, 2012   (RSS)

By nmsinc - May 22, 2012 - edited: May 22, 2012

I need to add city & state fields to the following CMS section drop down - see code below: ideas anyone?

Thanks - nmsinc

-----------------------------------------------------------------

<?php if ($CURRENT_USER['isAdmin']):?>
<?php
$where = "";
$where = "WHERE member_type = 'Insurance'";
?>
SELECT num, member_company_name
FROM `<?php echo $TABLE_PREFIX ?>member_companies`
<?php echo $where; ?>
ORDER BY member_company_name

<?php elseif (!$CURRENT_USER['isAdmin'] AND $CURRENT_USER['company_type'] == "Independent"): ?>
<?php
$where = "";
$where = "WHERE member_type = 'Insurance'";
?>
SELECT num, member_company_name
FROM `<?php echo $TABLE_PREFIX ?>member_companies`
<?php echo $where; ?>
ORDER BY member_company_name

<?php else: ?>
<?php
$where = "";
$where = "WHERE num = '".$CURRENT_USER['member_company_accounts']."'";
?>
SELECT num, member_company_name
FROM `<?php echo $TABLE_PREFIX ?>member_companies`
<?php echo $where; ?>
ORDER BY member_company_name

<?php endif ?>
-------------------------------------------------------------------
nmsinc

Re: [ross] Multiple Fields in CMS Drop Down

By nmsinc - May 31, 2012

Hi Ross,

Sorry for the delay - this is within the CMS section editor and the city and state fileds are within the same table as the company name!

Thanks - nmsinc
nmsinc

Re: [nmsinc] Multiple Fields in CMS Drop Down

By Jason - June 1, 2012

Hi,

Are you looking to add the city and state to the option label of the drop down?

If so, you can use the mySQL CONCAT function like this:

SELECT num, CONCAT(member_company_name, "-", city, ", ", state)
FROM `<?php echo $TABLE_PREFIX ?>member_companies`
<?php echo $where; ?>
ORDER BY member_company_name


In this example, options would appear in the format

company_name - city, state

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/

Re: [Jason] Multiple Fields in CMS Drop Down

By nmsinc - June 1, 2012

That works - thanks Jason!

nmsinc
nmsinc