How to Reverse a MySQL Query in PHP

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.


    • 1

      Open your PHP file in your preferred text or PHP editor.

    • 2

      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

    • 3

      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);

    • 4

      Save your document. When PHP runs the file, your query string will be sent to the database in reverse order.

Related Searches


Related Ads

Check It Out

7 Tips for Photographing Your Kids on Halloween