note 25348 deleted from function.mysql-fetch-array by philip

From: Date: Sun, 08 Aug 2004 16:50:34 +0000
Subject: note 25348 deleted from function.mysql-fetch-array by philip
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-74250@lists.php.net to get a copy of this message
Note Submitter: jb@stormvision.com.na ---- This might be usefull for people that work with lots of rows and want to place them all into one array for later usage. This script just takes care of all the tedious work one would have and puts all neccessary field names into your array automatically. This way you can use this script over and over for all kind of mysql functions. $result=mysql_query("select * from mydata order by 'id'")or die('died'); $num_rows = mysql_num_rows($result); $j=0; $x=1; while($row=mysql_fetch_array($result)){ for($j=0;$j<$num_rows;$j++){ $name = mysql_field_name($result, $j); $object[$x][$name]=$row[$name]; }$x++; } For Later in the script you may use the below array to gain access to your data $i=1; $ii=count($object); //quick access function for($i=1;$i<=$ii;$i++){ echo $object[$i]['your_field_name']; } hope it helps

« previous php.notes (#74250) next »