RE: [PHP] Store data in array

From: Date: Mon, 18 Mar 2002 13:40:47 +0000
Subject: RE: [PHP] Store data in array
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-88920@lists.php.net to get a copy of this message
Hi Uma, you can use as in C language with index. $a[i]= $val; i is index starts from zero. For example u want to extract specific field from mysql database and store it in array.. Let us assume num is a attribute name of the table heap. ===================================================================== $sql="select num from heap"; $result=mysql_query($sql1) or die("Error in query sql".mysql_error()); $n=mysql_numrows($result); If( $n>0) { $i=0; While(($row=mysql_fetch_object($result))) { $a[$i]=$row->num; $i=$i+1; } } ===================================================================== Hope this helps. Best Regards Balaji -----Original Message----- From: Uma Shankari T. [mailto:umashankari@lantana.tenet.res.in] Sent: Monday, March 18, 2002 4:55 PM To: Andrey Hristov Cc: php-general@lists.php.net Subject: Re: [PHP] Store data in array On Mon, 18 Mar 2002, Andrey Hristov wrote: AH>If it is possible do the sorting in the SQL statement by using ORDER AH>BY. SQL sorting is much faster than in PHP. However I have gone through that manual already....but i need to sort by php sorting. AH>while ($row= mysql_fetch_assoc($res)){ $rows[] = $row; } AH> I have tried this but while sorting using php sort it is displaying array only.If the elements are stored in the array properly i can perform sorting. please tell me how to extract a specific field from mysql database and store it in array... AH>Then you have many ways to sort. Look at : sort(), asort(), arsort(), AH>usort(), uasort() etc. AH> AH>Best regards, AH>Andrey Hristov AH> AH>----- Original Message ----- AH>From: "Uma Shankari T." <umashankari@lantana.tenet.res.in> AH>To: <php-general@lists.php.net> AH>Sent: Monday, March 18, 2002 12:25 PM AH>Subject: [PHP] Store data in array AH> AH> AH>> AH>> AH>> Hello, AH>> AH>> Anyone can please tell me how to store the row details fetched from AH>> database to array so that to sort the same array after storing.... AH>> AH>> AH>> -Uma AH>> AH>> AH>> -- AH>> PHP General Mailing List (http://www.php.net/) AH>> To unsubscribe, visit: http://www.php.net/unsub.php AH>> AH>> AH> -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

**************************Disclaimer************************************ Information contained in this E-MAIL being proprietary to Wipro Limited is 'privileged' and 'confidential' and intended for use only by the individual or entity to which it is addressed. You are notified that any use, copying or dissemination of the information contained in the E-MAIL in any manner whatsoever is strictly prohibited. ********************************************************************
« previous php.general (#88920) next »