title: Exporting table to CSV via php button
body: <p>I am really new to php and everything I have learned is from my school textbook and online research. With that said I am trying to complete an assignment and I am stuck on the last part. for the final part the assignment says to <strong>"Create a PHP script that will dump the contents of the employee table into CSV text file that has comma separated values for each record. Each new record should begin on a new line"</strong>. I have tried many online tutorials but none of them teach how to put this event in a button. I am including my code so you can see the mess I have. It's not to bad but I am sure I can do the same task with much less code. Again I am just starting out and this is the best I can do for now. Could anyone give any suggestions on how this could be done. I have my button on line 140. I also used a db_connect() function so i don't have to write it many times. I can peon use this to read the database before I save as a csv.</p>
  
  <p>Any suggestions would be greatly appreciated. Be warned It's a lot of code to follow.</p>
  
  <pre><code>    &lt;h2&gt;Employee Search&lt;/h2&gt;
      &lt;form action="Draft.php" name="dbToCSV" method="GET"&gt;
          &lt;input type="submit" name="dbToCSV" value="Export Database to CSV" &lt;?php if     (isset($_GET['dbToCSV']))
                      {
                          //Do this code
                      }
                      else
                      {
                          echo "Error!";
                      } ?&gt;&gt;&lt;br /&gt;
  
      &lt;/form&gt;
      &lt;form action="Draft.php" method="GET"&gt;
          By name: &lt;input type="text" name="searchName"&gt;
          &lt;input type="submit" value="Search Name"&gt;&lt;br /&gt;
      &lt;/form&gt;
      &lt;form action="Draft.php" method="GET"&gt;
          By language: &lt;input type="text" name="searchLang"&gt;
          &lt;input type="submit" value="Search Language"&gt;&lt;br /&gt;
      &lt;/form&gt;
  </code></pre>