*Solved*multidimensional array w/o assigning to variable.
Posted: Tue Feb 20, 2007 10:38 pm
feyd | Please use
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
I'm trying to loop through some rows I've grabbed from the database and throw them into a multidimensional array. I'm having trouble figuring out how to do it. Below is what I have right now, but it is only saving the last row of information because "$b" doesn't work as an incremental variable. It just keeps overwriting. If anyone knows of a different way to do it, or how to fix my process please let me know! THX for looking.Code: Select all
$boxResults = mysql_query($queryBox) or die("box query failed");
$numrowsBox = mysql_numrows($boxResults);
if ($boxResults)
{//start if-3
$b=0;
while ($b < $numrowsBox )
{ //start while-1
$brow = mysql_fetch_assoc($boxResults);
$item = $brow['itemNum'];
$description = $brow['desc'];
$size = $brow['size'];
$inches = $brow['inches'];
$unit = $brow['unit'];
$unitP = $brow['unitsPerBox'];
$color = $brow['color'];
$priceP = $brow['pricePerBox'];
$optional = $brow['optional'];
$plat = $brow['plat'];
$boxArray = array( "$b" => array ("item" => $item,
"description" => $description,
"size" => $size,
"inches" => $inches,
"unit" => $unit,
"unitsPerBox" => $unitsP,
"color" => $color,
"pricePerBox" => $priceP,
"optional" => $optional,
"plat" => $plat,
)
); //end boxArray
$b++;
}//end while-1feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]