revjim.net

mysql_fetch_allrows()

For Brad.

Here is a PHP function that will grab all the rows from a mysql result identifier:

function mysql_fetch_allrows($res) {

	while($data[] = mysql_fetch_assoc($res)) {
		# nothing
	}

	return array_slice($data,0,-1);

}

Or, if you just want one field:

function mysql_fetch_field_allrows($res,$field) {

	while($data = mysql_fetch_assoc($res)) {
		$rtn[] = $data[$field];
	}

	return $rtn;

}