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: [nmsinc] Multiple Fields in CMS Drop Down

By ross - May 23, 2012

Hi there.

Is all of this code going into the custom field in your section editor? Also, are the city & state fields actually in the same table you are searching in?

There will be a way to make this all happen. Let's get me up to speed with how things are setup first though :).

Let me know what you think. Thanks!
-----------------------------------------------------------
Cheers,
Ross Fairbairn - Consulting
consulting@interactivetools.com

Hire me! Save time by getting our experts to help with your project.
Template changes, advanced features, full integration, whatever you
need. Whether you need one hour or fifty, get it done fast with
Priority Consulting: http://www.interactivetools.com/consulting/

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