I am trying to sort the result by a specific column of an array of bank data.
function cmp($a, $b) {
return strcmp($a['usu_codigo'], $b['usu_codigo']);
};
usort($usu_info_coluna, "cmp");
Giving var_dump
to $usu_info_Coluna
, it returns:
array(21) { ["usu_codigo"]=> int(1) ["usu_nome"]=> string(5) "LUANN" ["usu_senha"]=> string(60) "$2y$10$I4RqdKD/cOwRDNpFgtIbWeVirNIfxHPREMEklGaBuONGRZMtQfUgq" ["usu_sobrenome"]=> string(5) "SOUSA" ["usu_cpf"]=> string(11) "12345678998" ["usu_rg"]=> string(9) "123456789" ["usu_nasc"]=> string(10) "2018-10-22" ["usu_endereco"]=> string(4) "AV 2" ["usu_numero"]=> string(2) "97" ["usu_bairro"]=> string(8) "BLOCO D2" ["usu_cep"]=> string(8) "11900000" ["usu_cidade"]=> string(11) "REGISTRO-SP" ["usu_uf"]=> string(2) "SP" ["usu_tel"]=> string(10) "1338226293" ["usu_cel"]=> string(11) "13997821923" ["usu_genero"]=> string(9) "Masculino" ["usu_situacao"]=> string(5) "ativo" ["usu_email"]=> string(22) "[email protected]" ["usu_indicador_codigo"]=> NULL ["usu_datacadastro"]=> string(10) "2018-10-22" ["usu_nivel"]=> string(3) "adm" }
What did I miss using usort? I changed and changed the usort code, but it always gives me a different error, and I believe this was the closest I got.
UPDATE 0 : This is the prepared query I use for the query:
$_SESSION['codigo'] = 1;
$usu_codigo = $_SESSION['codigo'];
$usu_situacao = 'ativo';
$stmt3 = $conexao->prepare('SELECT * FROM esc_usuarios WHERE usu_indicador_codigo = ?');
$stmt3->bind_param('i', $usu_codigo);
$stmt3->execute();
$usu_ult5_cad = $stmt3->get_result();
Displaying Through a Table:
<?php
$limit = 2;
while($limit -- && $coluna_ult5 = $usu_ult5_cad->fetch_array()){
?>
<tbody>
<tr>
<th><?php echo $coluna_ult5['usu_codigo']; ?><br></th>
<td><?php echo $coluna_ult5['usu_nome']; ?></td>
<td><?php echo $coluna_ult5['usu_sobrenome']; ?><br></td>
</tr>
<?php }
? >