Jump to content

Make assoc array from query results...


RIRedinPA

Recommended Posts

If I have a db with these fields: displayname, title

 

and I run a successful query on the db, will this code:

 

 

if (mysql_num_rows($results) == 0) {

return "!fail";

} else {

while ($row = mysql_fetch_assoc($results)) {

    extract($row);

}

 

return $row;

}

 

 

create an associative array of $var = array(array('displayname' => value, 'title' => value), array('displayname' => value, 'title' => value)...)

 

If not, is there a way to do so, especially when I will not know the names or number of fields in a db table?

Link to comment
https://forums.phpfreaks.com/topic/219604-make-assoc-array-from-query-results/
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.