Home | Photography | Flickr | LiveJournal | Get Firefox

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;

}
Share and Enjoy:
  • Facebook
  • StumbleUpon
  • Digg
  • e-mail
  • del.icio.us
  • Google
  • Reddit
  • Technorati
  • BlinkList
  • blogmarks
  • Blue Dot
  • description
  • Furl
  • Ma.gnolia
  • MisterWong
  • Netvouz
  • PlugIM
  • Propeller
  • Simpy
  • Spurl
  • TailRank

Trackbacks

blog comments powered by Disqus