I have code like this:
function artykul_firmy_z_branzy($art_id, $limit) {
return select("
select f.id from artykuly a, firmy f where a.display = true
and a.id_branzy = f.branza_id and a.id = :id and f.profil <> 0 order by f.profil desc, f.firma asc limit ${limit}
", array('id' => $art_id));
}
This code should choose some rows from sql database and sort it, and it works great, but result, which has the biggest "f.profil" is always on the end of list, when I change limit to "1", then I got only this result with biggest f.profil, so ordering works, but how to show this on the first position?
Code in template, which shows results:
{% if firmy_z_branzy_logo %}
<div class="firmy-z-branzy">
<img src="/static/screw.png" class="label-screw" /> <div class="label-title">FIRMY Z TEJ BRANŻY</div>
<div style="clear: both;"></div>
{% for i in firmy_z_branzy_logo %}
<div class="firma-branza"><a href="/wizytowka/{{ i.id_firmy }}"><img src="/{{ i.sciezka }}m/{{ i.plik }}" / style="margin-bottom:6px;"></a>{{ i.opis }}</div>
{% endfor %}
</div>
{% endif %}