Page 1 of 1

Building an associative array form DB

Posted: Sat Aug 11, 2007 3:42 pm
by GeXus
I have a table with the following:

id, name, user, pass, date

I want select from it and format it so it returns like this....

Code: Select all

$val = array("id" => 1,
             "name" => "person",
             "user" => "persons name",
             "pass" => "persons pass",
             "date" => ""
            );
This way I can use json_encode and have it formatted properly.... how would I set it up to return an array formatted like that?

Posted: Sat Aug 11, 2007 5:23 pm
by programmingjeff
$val = mysql_fetch_assoc($resource);