Add Order By to sql_select statement

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

By Djulia - May 17, 2015 - edited: May 18, 2015

Hi,

Try this :

<?php $submissionRecords = mysql_select('submission', $where); ?>

Name:&nbsp;
<select name="num">
<?php 
    $lastName = array();
    foreach ($submissionRecords as $key => $row) {
        $lastName[$key] = $row['last_name'];
    }
    array_multisort($lastName, SORT_ASC, $submissionRecords); // or SORT_DESC
    foreach ($submissionRecords as $submissionRecord): ?>
<option value = "<?php echo$submissionRecord['num'];?>">#<?php echo $submissionRecord['num']; ?> - <?php echo $submissionRecord['last_name']; ?>, <?php echo $submissionRecord['name']; ?></option>
<?php endforeach ?>
</select>

Thanks!

Djulia

By nmsinc - May 18, 2015

Thanks Djuilia - worked perfect!

nmsinc