arrays and nested arrays and loops and databases...

From: Date: Sat, 18 Jan 2003 23:38:49 +0000
Subject: arrays and nested arrays and loops and databases...
References: 1  Groups: php.windows 
Request: Send a blank email to php-windows+get-17968@lists.php.net to get a copy of this message
Well... I can usually puzzle myself through these things, but I figured it's time to ask the list. :) It may be a simple thing that I'm missing, but here's what I have. The structure that I'm trying to modify is as follows: $to = array( array( 'address'=>'user@domain.com', 'name'=>'Bob Smith' ), array( 'address'=>'otheruser@otherdomain.com', 'name'=>'John Jones' ) ); That said, I have a database of names and email addresses which I want to insert into this structure, but in a loop since I don't want to have an array() section for each one, not knowing how many are going to be in the list at the time this script is run. I want to loop the 'sub' array() statements so that I can build up the main array(). I use mysql as follows: $query = "select email, fullname from tablename where updateannounce = 1"; $result = mysql_query($query); while ($output = mysql_fetch_array($result)) { //This is where I want the loop of arrays to appear, so I can dynamically insert the email and fullname fields into the obvious spots } I need to figure out how to do this, essentially: $to = array(<loop to fill other array() statements>); I don't know how to get that loop to work inside the overall array() statement, though... any assistance would be greatly appreciated. Thank you, Marc

« previous php.windows (#17968) next »