setQuery($query);I have order by at his end, but it dosen't work. I don't know how to manage this situation... what i have to do to make it work?"> Order By not working. - Forums

Forums

Order By not working.

myky2k1 15 Apr, 2016
Hello community. Last week i've asked here a question and GreyHead helped me alot. I've solved that problem.


Now, i have another little problem. I have this query:

$query = "
SELECT Distinct
`I31`.`codmod`,
`I31`.`desmod`
FROM `IDAT2410F` AS I24
LEFT JOIN `IDAT3200F` AS I32
ON `I32`.`CODALL` = `I24`.`CODALL`
LEFT JOIN `IDAT3100F` AS I31
ON `I31`.`CODMAR` = `I32`.`CODMAR` AND `I31`.`CODMOD` = `I32`.`CODMOD`
WHERE
`I24`.`ANNOXX` BETWEEN '".$an2."' and '".$an."'
AND `I32`.`codmar` = '".$marca."'
ORDER BY `I31`.`desmod`";
$db->setQuery($query);

I have order by at his end, but it dosen't work. I don't know how to manage this situation... what i have to do to make it work?
GreyHead 15 Apr, 2016
Hi myky2k1,

The query looks OK to me, you can echo it out, or add a debugger to see the query that has been built and test that in PHPMyAdmin to see what error that shows.

Bob
myky2k1 15 Apr, 2016
The query works flawless. But i pass the data with json_encode($options) and in the dropdown, are ordered by key, not by value.
GreyHead 15 Apr, 2016
Hi myky2k1,

Ah, that is a different question. The query works OK but the way that ChronoForms handles the resulting array has a bug that ignores the order. There is a fix for it but it requires a small code hack. Please check this post.

Bob
This topic is locked and no more replies can be posted.