<?php
$search = 'item1';
$con = require_once('./dbconnect.php');
mysql_select_db("packages", $con);
$package = mysql_query("SELECT * FROM $search", $con);
while($item = mysql_fetch_row($package)){
$arr[$item[1]] = array('description' => $item[2], 'image' => $item[3]);
}
echo json_encode($arr);
mysql_close($con);
?>
So the loop works and does actually create the array with the various 'packages' in their respective array. The issue that i am having is that mysql_fetch_row($package)) can and will contain multiple keys that are the same name but with different things in the array.
For example, the database will be something like this:
PACK LEV DESCRIPTION IMAGES
item1 A1 description for stuff1 image1
item1 A2 description for more stuff image2
item1 B1 more stuff here image3
item2 A1 description here for item2 image1
item2 B1 description contents here image2
---------------------------------------------------------------------------------
My Above code will produce an array like this:
Array ( [item1] => Array ( [description] => more stuff here [image] => image3 ) [item2] => Array ( [description] => description contents here [image] => image2 ) )
What i want the array to be is:
Array ( [item1] => Array ( [A1] => Array ( [description] => description for stuff1 [image] => image1 ) [A2] => Array ( [description] => description for more stuff [image] => image2 ) [B1] => Array ( [description] => more stuff here [image] => image3 ) [item2] => Array ( [A1] => Array ( [description] => description here for item2 [image] => image1 ) [B1] => Array ( [description] => description contents here [image] => image2 ) ) )
I hope this makes sense..Thanks for looking











