title: How to display pg_query results in a table using PHP?
body: <p>I'm trying to display the results of my query in a neatly formatted table but I'm pretty new to PHP so I'm at a bit of a loss. Currently I have this:</p>
  
  <pre><code>$dbconn = pg_connect("host=localhost port=5432 dbname=mary");
  $result =  pg_query($dbconn, $selectStmt);
  $resultArr = pg_fetch_all($result);
  print_r($resultArr);
  </code></pre>
  
  <p>Assume <code>$selectStmt = SELECT State, Name FROM perez.pop WHERE Name LIKE '%Alabama%';</code>
  When I print this, I get the following:</p>
  
  <pre><code>Array ( [0] =&gt; Array ( [state] =&gt; 1 [name] =&gt; Alabama ) )
  </code></pre>
  
  <p>How could I place this into a table where the columns are "state" and "name" along with one more column in which I plan to place a link to a different page?</p>
  
  <p>Also, can anyone clarify how the <code>$resultArr</code> looks when I get multiple rows as a result of my query?</p>
  
  <p>EDIT: I'd like the output to look something like this:</p>
  
  <pre><code>State       | Name        | Follow link
  ___________________________________________________
  32          Alabama       &lt;some link to a php page&gt; 
  2           Alabama       &lt;another link&gt;
  </code></pre>