<?php
function user_re_order ($a, $b) {
$rv = dbx_cmp_desc ($a, $b, "parentid");
if (!$rv) $rv = dbx_cmp_asc ($a, $b, "id");
return $rv;
}
$link = dbx_connect ("odbc", "", "db", "username", "password")
or die ("Could not connect");
$result = dbx_query ($link, "SELECT id, parentid, description FROM tbl ORDER BY id");
echo "resulting data is now ordered by id<br>";
dbx_sort ($result, "user_re_order");
echo "resulting data is now ordered by parentid (descending), then by id<br>";
dbx_close ($link);
?>
|