0
opa, everything right?! I took this script to give continuity and has the select that brings me the database data. I’m having difficulty in doing Multisort.
<?php
$sql = mysql_query("select if(extra50 = 0, '', extra50) AS extra50, if(extra100 = 0, '', extra100) AS extra100, if(extra50not = 0, '', extra50not) AS extra50not, if(extra100not = 0, '', extra100not) AS extra100not, ds_nome from resumida_" . $cd_ano . " where cd_mes = " . $cd_mes . " ", $conexao);
while ($RR = mysql_fetch_array($sql)) {
$motorista[$m]['nome'] = strtoupper($RR["ds_nome"]);
$motorista[$m]['hr50'] = $RR["extra50"];
$motorista[$m]['hr100'] = $RR["extra100"];
$motorista[$m]['hr51'] = $RR["extra50not"];
$motorista[$m]['hr101'] = $RR["extra100not"];
if ($cd_ordenar == 50) {
foreach ($motorista as $res)
$sortAux[] = $res['hr50'];
}
if ($cd_ordenar == 51) {
foreach ($motorista as $res)
$sortAux[] = $res['hr51'];
}
if ($cd_ordenar == 60) {
foreach ($motorista as $res)
$sortAux[] = $res['hr60'];
}
if ($cd_ordenar == 100) {
foreach ($motorista as $res)
$sortAux[] = $res['hr100'];
}
if ($cd_ordenar == 101) {
foreach ($motorista as $res)
$sortAux[] = $res['hr101'];
}
if ($cd_ordem == 1) {
array_multisort($sortAux, SORT_DESC, $motorista);
}
if ($cd_ordem == 0) {
array_multisort($sortAux, SORT_ASC, $motorista);
}
foreach ($motorista as $vl) {
$html .= "<tr>";
$html .= "<td>" . $vl['nome'] . "</td>";
$html .= "<td align='center'>" . MinToHrMinB($vl['hr50']) . "</td>";
$html .= "<td align='center'>" . MinToHrMinB($vl['hr100']) . "</td>";
$html .= "<td align='center'>" . MinToHrMinB($vl['hr51']) . "</td>";
$html .= "<td align='center'>" . MinToHrMinB($vl['hr101']) . "</td>";
$html .= "</tr>";
$tot50 += $vl['hr50'];
$tot51 += $vl['hr51'];
$tot100 += $vl['hr100'];
$tot101 += $vl['hr101'];
}
}
$cd_sort and $cd_order comes from a header to sort as described in the script. I tried some ways printing on the screen to see how I was progressing but I didn’t succeed. He just doesn’t order. Always keep the same result scheme.