Using PHP’s var_dump() to Display SQL Query Results

Using the power of PHP’s var_dump() displays structured information about one or more expressions that includes its type and value. By definition var_dump() is a debugging tool, which displays structured information about any PHP variable. Below is a handy bit of code using var_dump() to test and verify that a SQL query contains data and view the contents using PHP:

$sql = mysql_query("SELECT * FROM your_table WHERE key = 'value'");
$assoc = mysql_fetch_assoc($sql);

// Dump variable containing the result of the MySQL query


This was a pretty simple example for exporting the results of a SQL query using vardump(). Using this bit of code we will receive structured information about our SQL query that includes its types and values.

13 thoughts on “Using PHP’s var_dump() to Display SQL Query Results

  1. Thanks for posting this. I have been trying to figure out how to display all the results of a mysql query all morning with no luck. Just want to make sure I’m getting back what I’m expecting!

  2. Moviebox is a very popular app that allows you to watch movies on your android, iOS, blackberry and even on your windows

    devices and PC. It is absolutely free of cost and there is no annoying wait for your videos to buffer. Also it does not take

    up too much space to install and is also easy going on your RAM. So if you are a moviebuff and want to watch movies on your

    smartphones, then this app is a must have for you. To install the app just click
    Moviebox for Windows

Leave a Reply

Your email address will not be published. Required fields are marked *