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;

}

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>