|
Last updated: 09/04/2010
This function takes a database link ($link), SQL statement ($sql) and array ($all_rows), and returns the result from the query in the array ($all_rows) which is passed in by reference.
function select_sql_rows ($link,$sql,&$all_rows) {
$r = mysql_query($sql,$link);
if (!$r) {
$message = 'Invalid query: ' . mysql_error() . "\n";
$message .= 'Whole query: ' . $sql;
print $message;
exit;
}
while ($results = mysql_fetch_array($r, MYSQL_ASSOC)) {
array_push($all_rows,$results);
}
$rows = mysql_num_rows($r);
//print "Got: $rows rows \n";
mysql_free_result($r);
return($rows);
}
|