i have got a mysql database with words. I am printing all the words with a while statement. So i get like:
potato tomato lettace
This is all working fine, but i want to sort the words by length. I have tried:
if(strlen($go['words']) == 4 ){ echo "this are the 4 letter words:"; }
but this will print the sentence before every 4 letter word. Whereas, I want it to be printed only 1 time as a header for all 4 letter words. Of course i want to do this also for 5,6,7 letter words.
I have thought about making multiple sql query's but thats too much for the server to handle with a lot of visitors.