Creating a Dynamic Array with a Loop
<p>I am looking to create a dynamic Array that outputs an array containing database results from any given table name</p>

<pre><code>&lt;?php
    $query = "SELECT * FROM $tableNames ";  

    //returns the db rows in an array
    $field_array = $dbo-&gt;query($query);

    //used to get the column titles form an array
    $columns = $dbo-&gt;query("show columns from $tableNames");

    $arr =  array();  

    /* Show an message is there are no products */
    if (!sizeof($field_array)) {
        $dbErrorss =1;
    }

    /* Otherwise show the product list */
    else {
        //outputs the db results
        foreach($field_array as $field){


        for($count=0;$count&lt;10;$count++){ 
            $newRow = array(
             $columns[$count]['Field'] =&gt; $field["{$columns[$count]['Field']}"],
            );
            $arr = array_merge($arr, $newRow);


        }

        }

    }

?&gt;
</code></pre>

<p>basically i would like it to output where job_title, location etc are the column names from the db </p>

<pre><code>         $arr[]= array(
             job_title =&gt; $field['job_title'],
             location =&gt; $field['location'],
             wage =&gt; $field['wage'],
             description =&gt; $field['description'],
             date_added =&gt; $field['date_added'],
             full_time =&gt; $field['full_time'],
             category_name =&gt; $field['category_name'],
             category_id =&gt; $field['category_id'],
             online =&gt; $field['online'],
     keywords =&gt; $field['keywords'],
         );
</code></pre>

<p>Cheers for any help</p>
