In programming, NOTHING hanppens automatically. You're going to have to writ ethe code to do what you want.
Your question is very generic, so the best anyone can do is give you
this[
^].
You're not the first person to try and get data from a database and it's been documented and demonstrated millions of times all over the web.