title: Getting data from database not working properly
body: <p>I'm using this form and query to pull out information stored in a database, the problem that I'm having is that if the <code>studentcode</code> is a number it works fine, but if the code is letter it don't work and I don't know what can be causing this, any ideas?</p>
  
  <pre><code>&lt;form action="classgrades.php?id=&lt;?php echo $courseid ?&gt;" method="post"&gt;
       &lt;input type="text" name="studentCode" value="" placeholder="Student Code.." /&gt;
       &lt;button type="submit" value="Submit"&gt;Submit&lt;/button&gt; 
  &lt;/form&gt;
  
  $studentcode = $_POST['studentCode'];
  $query = "SELECT s.studentid, s.assignmentid, s.studentpoints,
                   a.assignmentid, a.assignmentname, a.assignmentpoints
            FROM studentgrades AS s, assignments AS a  
            WHERE a.assignmentid = s.assignmentid
            AND s.courseid = $courseid
            AND s.studentid = (SELECT studentid
                               FROM students
                               WHERE studentcode = '$studentcode')";
  </code></pre>
  
  <p>Database </p>
  
  <pre><code>CREATE TABLE IF NOT EXISTS `students` (
    `studentid` int(11) NOT NULL AUTO_INCREMENT,
    `fname` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
    `lname` varchar(64) COLLATE utf8_unicode_ci NOT NULL,
    `studentcode` varchar(16) COLLATE utf8_unicode_ci NOT NULL,
    `courseid` int(11) NOT NULL,
    PRIMARY KEY (`studentid`)
  ) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=21
  
  CREATE TABLE IF NOT EXISTS `assignments` (
    `assignmentid` int(11) NOT NULL AUTO_INCREMENT,
    `assignmentname` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
    `courseid` int(11) NOT NULL,
    PRIMARY KEY (`assignmentid`)
  ) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=27 ;
  </code></pre>
  
  <p>Example of data record
  Students table</p>
  
  <pre><code>studentid   - 19;
  fname       - lizt;
  lname       - tisz;
  studentcode - cd;
  courseid    - 22;
  </code></pre>
  
  <p>Assignemt table</p>
  
  <pre><code>assignmentid   - 3;
  assignmentname - Hello;
  courseid       - 22;
  </code></pre>