How to Run query to get data from database using php ?
To run basic queries in php first you must have a database and a table in it.
Firstly you have to build a connection with MySql Database. If you are having confusion in
building a connection using MySql and PHP you should refer to my article on How to connect to Database using PHP:
Now head over to the Code Part:
After the connection is built up you decide what to do with the database now.
Run query to get data from database:
Now the result variable will contain the rows returned by the query and we will get them
by looping through result.
that we can access it inside the loop.
Thats it !!
Combine the connection part, the query part and the looping part together and run the file and it will return all rows in that table and display them.
Thanks for reading !!