I have a situation with my php code. In a previous page the user enters in their username. Now when they submit the form, the username is posted and echo on the current page.
E.G if the teacher entered in ‘j.lu’ as the username, it posts ‘j.lu’ on the current page.
But what I want to do is that I want the insert the teacher’s Id in the database. To do this I set up a query to select the teacher’s Id by finding it’s username. So ‘j.lu’ has a TeacherId ‘T1’ but it does not display this is the field when inserted. Instead it states ‘SEL’ in the field.
So my question is that what does ‘SEL’ mean and how can I fix it so instead of saying ‘SEL’ it will state the teacher’s id which in this example is ‘T1’.
Below is code of the query, insert and the echo:
$teacherid = "SELECT TeacherId FROM Teacher WHERE (TeacherUsername = '".mysql_real_escape_string($_SESSION['teacherusername'])."')";
echo $_SESSION['teacherusername'];
$sql="INSERT INTO Session (TeacherId)
VALUES
(' ". mysql_real_escape_string( $teacherid ) . "')";
mysql_query($sql);
SEL are the first three chars of the word SELECT as the query you run is
You need to change the $teacherid content:
As far you have a table called Session …
edit
Instead of using the username as is, the you have to execute the first query: