title: Query the Postgres DB table data from HTML webpage using PHP
body: <p>I have a postgres database table with 6 columns</p>
  
  <pre><code>  report_dt      | configured_capacity_tb | present_capacity_tb | dfs_remaining_tb | dfs_used_tb | env
  </code></pre>
  
  <p>The 5th column should appear as a drop down in HTML webpage when i select an option from that drop down and hit submit I should get the data(from postgres db table) in a form of table on webpage</p>
  
  <p>Any help greatly appreciated following is my broken code</p>
  
  <pre><code> echo 'Connection attempt succeeded.';
   } else {
   echo 'Connection attempt failed.';
   }
  $sql =&lt;&lt;&lt;EOF
  select * from cluster_report_tab;
  EOF;
  $ret = pg_query($db, $sql);
     if(!$ret){
        echo pg_last_error($db);
        exit;
  }
  &lt;&lt;&lt;I AM STUCK AT THIS PIECE&gt;&gt;&gt;&gt;
  
  &lt;html&gt;
  &lt;head&gt;&lt;title&gt;Cluster Report&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;p&gt;&lt;/p&gt;
  &lt;table width="600" cellpadding= "10" cellspacing="1" border="2"&gt;
  &lt;tr align="center" valign="top"&gt;
  &lt;td align="center" colspan="1" rowspan="1" bgcolor="#64b1ff"&gt;
  &lt;h3&gt;Hadoop Cluster Report&lt;/h3&gt;
  ****DROP DOWN SHOULD COME HERE*****
  &lt;input type="Submit" name="submit" value="Submit"&gt;
  &lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/form&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>When I select the option from that drop down and hit submit button on webpage It should display me the query result# select * from cluster_report_tab where env='DHEP'; on the webpage.</p>
  
  <p>Thanks</p>