Sorting in MySQL query get options

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

Re: [nmsinc] Sorting in MySQL query get options

By Jason - January 30, 2012

Hi,

You need to add ORDER BY member_company_name to the end of your query like this:

<?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 ?>


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] Sorting in MySQL query get options

By nmsinc - January 30, 2012

Thanks Jason, worked great!
nmsinc