What a loooooong list!
i wanna know if your DB is empty? :) for ($i=0; $i <$num_results; $i++)
This line may cause it, for the codes below has nothing to do with Var i, use "while{}" instead.Then make sure your SQL query is available, you could type this query in the command line, if that's no problem. Everything will be OK!