Open your PHP file in your preferred text or PHP editor.
Sometimes the data source you read your query from will need to be read in a reversed order. Each MySQL query is a simple string of data in PHP and can be reversed using standard PHP functions. Once a backwards data string has been reversed it can be fed directly into a MySQL database as a query.
Scroll down to the part of your code where your query is obtained or defined, but before it is sent to the database using the mysql_query function
Type the "strrev" command function before the query text. For example, if your query is stored in the variable you would type "$query_1" type:$query_1 = strrev($query_1);
Save your document. When PHP runs the file, your query string will be sent to the database in reverse order.