note 31881 deleted from function.mysql-fetch-row by philip

From: Date: Mon, 26 Feb 2007 06:56:19 +0000
Subject: note 31881 deleted from function.mysql-fetch-row by philip
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-123875@lists.php.net to get a copy of this message
Note Submitter: ---- 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.

« previous php.notes (#123875) next »