This is a quick guide on how to format sql queries to be placed in a php file. To format sql queries. Just type your query as usual without trying to format it. Copy it then paste it on the sql query text area on Phpmyadmin. Execute the query. And if its correct then just copy the formatted version of your query and paste it on your php code. Experimenting on queries in Phpmyadmin is also useful especially if you are not sure of the the query that you’re trying to execute.