title: Database Query into Associative Array using PHP
body: <p>I am trying to grab data from my database and place in a format so I can call field1 and return field2.</p>
  
  <p>In my mind I think this:</p>
  
  <pre><code>while($row = mysqli_fetch_assoc($result)) {
      $aa = $row["field1"];
      $bb = $row["field2"];
  }
  
  $cc = array(“$aa”=&gt;”$bb”);
  </code></pre>
  
  <p>Will compute this:</p>
  
  <pre><code>$cc = array(
      "Row1a"=&gt;"Stuff in field2 row1b",
      "Row2a"=&gt;"Stuff in field2 Row2b",
      "Row3a"=&gt;"Stuff in field2 Row3b",
      "Row4a"=&gt;"Stuff in field2 Row4b",
      );
  </code></pre>
  
  <p>After this I will be able to:</p>
  
  <pre><code>echo $cc('Row1a');
  </code></pre>
  
  <p>To display:</p>
  
  <pre><code>Stuff in field2 row1b
  </code></pre>