09-10-2009, 12:29 AM
|
#4 (permalink)
|
|
The Addict
Join Date: May 2009
Posts: 287
Thanks: 5
|
PHP Code:
// Credit should be given to wordpress, I've been studying // their code and came across this, it really is nice. $query = mysql_query('SELECT * FROM entries ORDER BY ID DESC');
foreach ($query as $data) { $results = mysql_fetch_assoc($data); }
// Now you should have an associative array // with all of the rows returned from the query. // So, we can just print them out to show you. print_r($results);
The reason that " mysql_fetch_array()" was not working is because it accepts two arguments (2nd is optional but recommended):
$result - The MySQL query...
$type - How you want the data back, numeric or assoc. $data[0] vs $data['name']
E.G. mysql_fetch_array($query, MYSQL_ASSOC);
|
|
|
|