Re: Basic Dual Query Combine into one question
| From: | dealTek | Date: | Fri, 30 Jan 2015 00:45:35 +0000 |
| Subject: | Re: Basic Dual Query Combine into one question | ||
| References: | 1 2 3 4 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-324325@lists.php.net to get a copy of this message | ||
On Jan 29, 2015, at 4:29 PM, Christoph Becker <cmbecker69@gmx.de> wrote:
> Assuming that $test_result->getRecords() returns an array[1], you could
> do the following:
>
> <?php
> $records = $test_result->getRecords();
> // sort by last name
> usort($records, function ($a, $b) {
> return strcmp(
> $a->getField('Contact_Last'),
> $b->getField('Contact_Last')
> );
> });
> ?>
> <?php foreach ($records as $test_row) { ?>
> <!-- the rest as before -->
>
> --
> Christoph M. Becker
YIPPEE THAT WORKED!!!!!!!!!!!! THANK YOU SO MUCH Christopher!!!!!
<?php
$records = $test_result->getRecords();
// sort by last name
usort($records, function ($a, $b) {
return strcmp(
$a->getField('Contact_Last'),
$b->getField('Contact_Last')
);
});
?>
<?php foreach ($records as $test_row) {
?>
<?php echo $test_row->getField('ID'); ?>
<?php echo $test_row->getField('Contact_Last'); ?>
<?php echo $test_row->getField('State'); ?>
<br />
<?php
}
?>
!SUPER!
Q: I think when I tried to sort on numeric field is came back as text type sort...
Is there a way to designate a numeric sort on certain fields?
see... when sort on numeric id field...
187 xxx
200 xxx
201 xxx
21 xxx
22 xxx
222 xxx
224 xxx
etc...
Q: Is it also possible to sort a more than 1 field like sort on Contact_Last & also State field
at same time?
--
Thanks,
Dave - DealTek
dealtek@gmail.com
[db-15]