Note that there are some explanatory texts on larger screens.

plurals
  1. POPHP/mySQL multi-dimensional array or object oriented approach?
    primarykey
    data
    text
    <p>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</p> <p>so essentially I want to have: </p> <ul> <li>CompanyID 1: ProductID 1: all the info about that specific product</li> <li>CompanyID 1: ProductID 2: all the info about that specific product</li> <li><p>CompanyID 1: ProductID 3: all the info about that specific product</p></li> <li><p>CompanyID 2: ProductID 1: all the info about that specific product</p></li> <li>CompanyID 2: ProductID 2: all the info about that specific product</li> </ul> <p>etc etc</p> <p>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.</p> <pre><code>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'];} </code></pre> <p>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?</p> <p>EDIT: right now i have this in the while loop: </p> <pre><code> $companyIDArray[$companyid] = $productidArray[$productid] = $productInfoArray["CompanyName"]=$CompanyName; </code></pre> <p>and I am going to make one for each field. Is that the best way to do it?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload