Just thought I'd share these helper functions that I use to simplify processing of query results a bit:
<?php
function db_result_single($result) {
return ($row = mysql_fetch_row($result)) && isset($row[0]) ? $row[0] : false;
}
function db_result_array($result, $key_column = null) {
for ($array = array(); $row = mysql_fetch_assoc($result); isset($row[$key_column]) ? $array[$row[$key_column]] = $row : $array[] = $row);
return $array;
}
function db_result_array_values($result) {
for ($array = array(); $row = mysql_fetch_row($result); isset($row[1]) ? $array[$row[1]] = $row[0] : $array[] = $row[0]);
return $array;
}
?>
Naturally, comments [to my email, not here] are welcome.