I have data that I want to pull from a mySQL database and I want to sort it in an organized way so I can pull it later. I want to sort it in a matter where i have CompanyID $companyid: productID $productid: productName = $Product, industryName = $industry etc
so essentially I want to have:
- CompanyID 1: ProductID 1: all the
info about that specific product - CompanyID 1: ProductID 2: all the
info about that specific product -
CompanyID 1: ProductID 3: all the
info about that specific product -
CompanyID 2: ProductID 1: all the
info about that specific product - CompanyID 2: ProductID 2: all the
info about that specific product
etc etc
this is the while loop that pulls all the info, and where i will be storing it in either a multi-dimensional array or some object oriented class in PHP. either way, i’m not too sure how to go about doing it.
while ($row = mysql_fetch_array($result)){
$CompanyName=$row['CompanyName'];
$companyid=$row['companyid'];
$Product=$row['Product'];
$productid=$row['productid'];
$Industry=$row['Industry'];
$Link=$row['Link'];
$Keywords=$row['Keywords'];
$region=$row['region'];}
EDIT: I want to write a multi-dimensional array to capture all the data in an orderly manner. how would I go about writing that or is that even the best solution?
EDIT: right now i have this in the while loop:
$companyIDArray[$companyid] = $productidArray[$productid] = $productInfoArray["CompanyName"]=$CompanyName;
and I am going to make one for each field. Is that the best way to do it?
the above is untested code but it will give you an idea atleast how to do it.