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 studentcode 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?
<form action="classgrades.php?id=<?php echo $courseid ?>" method="post">
<input type="text" name="studentCode" value="" placeholder="Student Code.." />
<button type="submit" value="Submit">Submit</button>
</form>
$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')";
Database
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 ;
Example of data record Students table
studentid - 19;
fname - lizt;
lname - tisz;
studentcode - cd;
courseid - 22;
Assignemt table
assignmentid - 3;
assignmentname - Hello;
courseid - 22;