ORDER BY in PHP that does not ORDER nothing at all

0

I have a query in mysql

When I do it through PHP, I simply ignore the ordering as I need it (whatever field I try to order it from).

The problem is in PHP that's why I pass the code that I have to call that query:

$diaActual = date("Y-m-d");

$sql = "SELECT 
         id, 
         DATE_FORMAT(fec_dde, '%d-%m-%Y') AS fec_dde, 
         DATE_FORMAT(fec_hta, '%d-%m-%Y') AS fec_hta, 
         tit_eve, 
         organiz 
       FROM eventos 
       WHERE (fec_hta >= '$diaActual') 
       ORDER BY tit_eve;";

$resultado = $mysqli->query($sql);

much more below I load a table and I cross the data doing:

<?php 
    while($row = $resultado->fetch_array(MYSQLI_ASSOC)) {
?>

Can someone give me a hand?

the query in mysql and the same query with the same sorting criteria in the php page ...

    
asked by MNibor 11.07.2017 в 15:45
source

1 answer

2

You are missing the way you want to order it, DESC or ASC.

$sql = "SELECT 
             id, 
             DATE_FORMAT(fec_dde, '%d-%m-%Y') AS fec_dde, 
             DATE_FORMAT(fec_hta, '%d-%m-%Y') AS fec_hta, 
             tit_eve, 
             organiz 
       FROM eventos 
       WHERE (fec_hta >= '$diaActual') 
       ORDER BY tit_eve DESC;";

Here a good example of how to use the ORDER BY clause

    
answered by 11.07.2017 / 16:07
source