Jump to content

Php Array from query


thecableguy2011

Recommended Posts

Hi

 

I am trying to store the results of a mysql query into a php array. Here is the code i am using

 

$test = implode(",",$_GET['checkbox']);

        $query = mysql_query("SELECT categoryTitle FROM `category` where categoryid in ($test)");

        $test2 = array();

        while ($result = mysql_fetch_assoc($query))

        {

            $test2[] = $result;

       

        } 

        $test3 = implode(", ",$test2);     

        print_r($test3);

 

Everything works fine until implode the array. When i try to print after the implode the result is "Array, Array". if i remove the implode it prints "Array ( [0] => Array ( [categoryTitle] => Escalators & Lifts ) [1] => Array ( [categoryTitle] => Human Resource/Payroll/ Training ) )"

The values here are ture. Im thinking that its storing an array inside another array so cannot implode. Is there something i can do to solve this

Link to comment
https://forums.phpfreaks.com/topic/228778-php-array-from-query/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.