When you query with php, you are asking for a "result" object (or, to be syntactically correct, a resource). You then need to iterate through the object/array/resource/whatever in order to actually get your data.
root = tkinter.Tk()
buttons=[i for i in range(10)]
#If specific button is pressed, output "YES"
for num in buttons: