Re: 2D array

From: Date: Fri, 27 Jul 2001 12:52:26 +0000
Subject: Re: 2D array
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-59938@lists.php.net to get a copy of this message
That works OK Thank you Ajdin On Fri, 27 Jul 2001, Wagner Tomy wrote: > $my2darray = Array(); > > while(list($myname, $myphone, $myemail) = mysql_fetch_row($result)) { > $my2darray[$myname] = array($myphone, $myemail); > } > > Wagner Tomy > Editus S.A. > ----- Original Message ----- > From: "AJDIN BRANDIC" <abrandic@coventry.ac.uk> > To: "Wagner Tomy" <tomy.wagner@luxweb.lu> > Cc: <php-general@lists.php.net> > Sent: Friday, July 27, 2001 2:34 PM > Subject: Re: [PHP] 2D array > > > > Wag, > > > > I do not wish to push whole of the row into an array. > > Also I need the id of the parent array to be $myname; > > > > Ajdin > > > > On Fri, 27 Jul 2001, Wagner Tomy wrote: > > > > > $my2darray = Array(); > > > > > > while($row = mysql_fetch_row($result)) { > > > array_push($my2darray, $row); > > > } > > > > > > OR: > > > > > > for($i = 0; $i < mysql_num_rows($result); $i++) { > > > $row = mysql_fetch_row($result); > > > $my2darray[$i] = $row; > > > } > > > > > > Wagner Tomy > > > Editus S.A. > > > > > > ----- Original Message ----- > > > From: "AJDIN BRANDIC" <abrandic@coventry.ac.uk> > > > To: <php-general@lists.php.net> > > > Sent: Friday, July 27, 2001 2:18 PM > > > Subject: [PHP] 2D array > > > > > > > > > > Hi > > > > > > > > I have been trying to do this for hours now. > > > > I have a while loop (rows from mysql db) and on each pass I want to > pussh > > > > a new element into a 2D array, bot always end up with the last element > of > > > > the while loop. So: > > > > > > > > table mytable > > > > myname myphone myemail > > > > john 254688 jonh@here.com > > > > tom 789787 tom@there.net > > > > > > > > $myquery="select * from mytable"; > > > > > > > > while ($myrow = mysql_fetch_array($myrows)) { > > > > .. .. . . . > > > > > > > > $my2darray = array ($myname => array ($myphone,$myemail)); > > > > > > > > } > > > > > > > > $mycount=count(my2darray); // returns 1 > > > > > > > > while (list($key,$value) = each ($my2darray)) { > > > > echo"$key,"; > > > > echo"$value[0]"; > > > > echo"$value[1]<br>"; > > > > // retuns only one row with tom,798779,tom@there.net > > > > } > > > > > > > > How do I push multiple entries into a 2d array? > > > > > > > > I tried $my2darray[]=array(....... > > > > > > > > Regards > > > > > > > > Ajdin > > > > > > > > -- > > > > PHP General Mailing List (http://www.php.net/) > > > > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > > > > For additional commands, e-mail: php-general-help@lists.php.net > > > > To contact the list administrators, e-mail: > php-list-admin@lists.php.net > > > > > > > > > > > > > -- > > > PHP General Mailing List (http://www.php.net/) > > > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > > > For additional commands, e-mail: php-general-help@lists.php.net > > > To contact the list administrators, e-mail: php-list-admin@lists.php.net > > > > > > > > > > -- > > PHP General Mailing List (http://www.php.net/) > > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > > For additional commands, e-mail: php-general-help@lists.php.net > > To contact the list administrators, e-mail: php-list-admin@lists.php.net > > > >

« previous php.general (#59938) next »