note 96505 added to function.mysql-fetch-array

From: Date: Tue, 02 Mar 2010 20:56:12 +0000
Subject: note 96505 added to function.mysql-fetch-array
Groups: php.notes 
Request: Send a blank email to php-notes+get-166545@lists.php.net to get a copy of this message
To put the full result in one array, I wrote this function: <?php $query="select * from table_xyz"; $result = mysql_query($query) or die(mysql_error()); $arr_table_result=mysql_fetch_full_result_array($result); function mysql_fetch_full_result_array($result) { $table_result=array(); $r=0; while($row = mysql_fetch_assoc($result)){ $arr_row=array(); $c=0; while ($c < mysql_num_fields($result)) { $col = mysql_fetch_field($result, $c); $arr_row[$col -> name] = $row[$col -> name]; $c++; } $table_result[$r] = $arr_row; $r++; } return $table_result; } echo $arr_table_result[2]['id']; ?> ---- Server IP: 87.106.1.137 Probable Submitter: 89.245.93.247 ---- Manual Page -- http://www.php.net/manual/en/function.mysql-fetch-array.php Edit -- https://master.php.net/note/edit/96505 Del: integrated -- https://master.php.net/note/delete/96505/integrated Del: useless -- https://master.php.net/note/delete/96505/useless Del: bad code -- https://master.php.net/note/delete/96505/bad+code Del: spam -- https://master.php.net/note/delete/96505/spam Del: non-english -- https://master.php.net/note/delete/96505/non-english Del: in docs -- https://master.php.net/note/delete/96505/in+docs Del: other reasons-- https://master.php.net/note/delete/96505 Reject -- https://master.php.net/note/reject/96505 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#166545) next »