title: Newbie: Building an employee directory with scripts for add/edit/search/delete. Errors
body: <p>I am building an employee directory that has 3 simple forms. The first adds records, the second searches for records, the third searches then deletes records.I want to display all the records on the same page, and then when a search is done, just display those records that fit the search keyword.</p>
  
  <p>I have built the DB and the Table correctly. The first form adds records to the DB successfully. Before I make the search and delete forms work correctly I am trying to get the records to display. They are not displaying. Sometimes I can get my html table to display, but none of the records appear. However, I know that the records exist because I can see them in MyAdmin.</p>
  
  <p>I am getting this error right now, but my errors are changing by the moment as I try new things: Warning: mysql_fetch_array() expects parameter 1 to be resource, null given in C:\xampp\htdocs\Employees.php on line 84</p>
  
  <p>I would love some help to do the following:
  1. Help me understand why I am getting this error.
  2. Help me understand how to display my records (I've done this successfully before, but with a simpler task).</p>
  
  <p>I know this code is unfinished. I am building it piece by piece and trying to get each individual piece to function before I add the next. Thanks!</p>
  
  <pre><code>&lt;html&gt;
  &lt;body&gt;
  
  &lt;?php error_reporting (E_ALL ^ E_NOTICE);
  $keyword = $_GET['keyword']; ?&gt;
  
  &lt;?php
  
  $con = mysql_connect("localhost", "employees", "employeepw");
  if (!$con)
      {
      die('Could not connect: ' . mysql_error());
      }
  
  mysql_select_db("employees", $con);
  
  mysql_query("INSERT INTO employeeinfo (firstname, lastname, phone, email, department, position)
  VALUES ('$_POST[firstname]', '$_POST[lastname]', '$_POST[phone]', '$_POST[email]', '$_POST[department]', '$_POST[position]')");
  
  mysql_query($sql,$con);
  
          function buildQuery() {
  
          $keyword = $_GET['keyword'];
  
          $sql = "SELECT * from employeeinfo WHERE
                  (
                  firstname LIKE '%$keyword%'
                  OR
                  lastname LIKE '%$keyword%'
                  OR
                  phone LIKE '%$keyword%'
                  OR
                  email LIKE '%$keyword%'
                  OR
                  department LIKE '%$keyword%'
                  OR
                  position LIKE '%$keyword%'
                  )";
  
          return $sql;
  
          } ?&gt;
  
          &lt;form action="Employees.php" method="post"&gt;
          &lt;fieldset&gt;
          &lt;legend&gt;Submit Employee Info&lt;/legend&gt;
          Firstname: &lt;input type="text" name="firstname" /&gt;
          Lastname: &lt;input type="text" name="lastname" /&gt;
          Phone: &lt;input type="text" name="phone" /&gt;
          Email: &lt;input type="text" name="email" /&gt;
          Department: &lt;input type="text" name="department" /&gt;
          Position: &lt;input type="text" name="position" /&gt;
          &lt;input type=submit name=submit value=Submit /&gt;
          &lt;/fieldset&gt;
          &lt;/form&gt;
  
          &lt;form action="Employees.php" method=get&gt;
          &lt;fieldset&gt;
          &lt;legend&gt;Search Employee Info&lt;/legend&gt;
          &lt;label for="keyword"&gt;Enter Keyword&lt;/label&gt;
          &lt;input id="keyword" name="keyword" value="&lt;?php echo "$keyword"; ?&gt;" /&gt;
          &lt;input type=submit name=submit value=Search /&gt;
          &lt;/fieldset&gt;
          &lt;/form&gt;
  
          &lt;form action="Employees.php" method=get&gt;
          &lt;fieldset&gt;
          &lt;legend&gt;Delete Employee Info&lt;/legend&gt;
          &lt;label for="keyword"&gt;Enter Keyword&lt;/label&gt;
          &lt;input id="keyword" name="keyword" value="&lt;?php echo "$keyword"; ?&gt;" /&gt;
          &lt;input type=submit name=submit value=Delete /&gt;
          &lt;/fieldset&gt;
          &lt;/form&gt;
  
  &lt;?
  function getRecords()
  {
  $sql = buildQuery();
  
  $resource = mysql_query($sql);
  }
  
  while($row = mysql_fetch_array($resource)) { // The error is for this row
  $results[] = $row;
  }
  return $results;
  
  $records = getRecords(); {
  
  foreach ($records as $record) {
  
  }?&gt;
  
          &lt;table&gt;
          &lt;tbody&gt;
          &lt;table border='1'&gt;
          &lt;tr&gt;
          &lt;td&gt;&lt;?= $row['firstname']; ?&gt;&lt;/td&gt;
          &lt;td&gt;&lt;?= $row['lastname']; ?&gt;&lt;/td&gt;
          &lt;td&gt;&lt;?= $row['phone']; ?&gt;&lt;/td&gt;
          &lt;td&gt;&lt;?= $row['email']; ?&gt;&lt;/td&gt;
          &lt;td&gt;&lt;?= $row['department']; ?&gt;&lt;/td&gt;
          &lt;td&gt;&lt;?= $row['position']; ?&gt;&lt;/td&gt;
          &lt;td&gt;&lt;a href="Employees.php"&gt;Return to Search&lt;/a&gt;&lt;/td&gt;
          &lt;/tr&gt;
  
          &lt;? } ?&gt;
  
  &lt;/tbody&gt;
  &lt;/table&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>