Three problems.
ORDER BY dogs.affix LIMIT 5returns bottom 5 not top. It should beORDER BY dogs.affix DESC LIMIT 5to get the top.affixreturns eithernullor an emprty string and that’s why you are getting the first error. Define this field asint not null default 0in your database.- $total is not initialized. Assign it to 0 before the loop
1
solved How to get top five calculations only to appear