Sort list bay label

2 posts by 2 authors in: Forums > CMS Builder
Last Post: July 24, 2012   (RSS)

Re: [theclicklab] Sort list bay label

By Jason - July 24, 2012

Hi,

The function getListOptions() returns an array where the index is the option value, and the value is the option label. Once you have this, you can use the PHP function asort() to sort the array and output.

for example:

<?php
$listOptions = getListOptions('product_database', 'category');
asort($listOptions);
?>

<?php foreach ($listOptions as $value => $label): ?>
<option value = "<?php echo htmlspecialchars($value);?>"> <?php echo htmlspecialchars($label);?> </option>
<?php endforeach ?>


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/