note 31881 added to function.mysql-fetch-row

From: Date: Wed, 07 May 2003 21:10:11 +0000
Subject: note 31881 added to function.mysql-fetch-row
Groups: php.notes 
Request: Send a blank email to php-notes+get-47645@lists.php.net to get a copy of this message
Fetch Work Around As a possible work around to the earlier problem, you could buffer the result of the query into a 2D array. This could be used to similar a table, to an extence and would allow you, to use the results of the query as often as you like in any custom function. function mysql_buffered_query($data_select, $data_connection) { $sql_query = mysql_query($data_select, $data_connection); $sql_num_fields = mysql_num_fields($sql_query); $info_rows = 0; while($sql_fetch_rows = mysql_fetch_row($sql_query)) { $info_offset = 1; $info_columns = 0; while ($info_offset <= $sql_num_fields) { $info_elements[$info_rows][$info_columns] = $sql_fetch_rows[$info_columns]; $info_offset++; $info_columns++; } $info_rows++; } return $info_elements; } ACCESSED WITH ------------------------------------------------- $sql_table = "atable"; $sql_where = 908; $sql_select = "SELECT * FROM $sql_table WHERE field_id ='$sql_where'"; $myarray = mysql_buffered_query($sql_select, $sql_connection); ------------------------------------------------- You can the use $myarray (or whatever u wanna call it) in any array pre-built or custom function. -- http://www.php.net/manual/en/function.mysql-fetch-row.php http://master.php.net/manage/user-notes.php?action=edit+31881 http://master.php.net/manage/user-notes.php?action=delete+31881 http://master.php.net/manage/user-notes.php?action=reject+31881

« previous php.notes (#47645) next »