Hi Nemonoman,
Thank you for responding to my thread. I have worked on the problem to no avail. However, I have decided to approach it from another angle.
I just want a system that will help each user obtain his/her record when he/she logs in. What I have now looks like this (see link): http://lhsnyc.net/php_practice/get_data6.php
Please could you help me with the code that will help each user get his/her data when he/she logs in? Below, please find what I have so far.
Thanks.
=============================================
******get6login.html*******
<html>
<head>
<title>Log-in Page</title>
</head>
<body>
Please complete the following fields to log in.
<form action="get_data6.php" method="post">
Student ID:<br>
<input type="text" name="studentid">
<br><br>
Password:<br>
<input type="password" name="password">
<br><br>
<input name="login" type="submit" id="login" value="Log in">
</form>
</body>
</html>
****get_data6.php******
<html>
<head>
<title>get data</title>
</head>
<body>
<?php
#connect to MySQL
$dbh=mysql_connect ("localhost", "username", "<password>")
or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("lhsnycne_dbname");
#select the specified database
$rs = @mysql_select_db("lhsnycne_dbname", $dbh)
or die("Err😃b");
#create the query specifying the required id
#$sql="select id,first_name,last_name,password from my_table where id=4"
$sql="select TEACHERCLASS.period, SCHEDULE2.classcode, TEACHERCLASS.room,
TEACHERCLASS.teacherlname, TEACHERCLASS.days, STUDENT2.studentid
FROM
TEACHERCLASS, STUDENT2, SCHEDULE2
WHERE
TEACHERCLASS.classcode = SCHEDULE2.classcode AND
STUDENT2.studentid = SCHEDULE2.studentid
order by period" ;
#execute the query
$rs=mysql_query($sql,$dbh);
#start table
$list = "<table border=\"1\" cellpadding=\"2\">";
$list.="<tr><th>ID</th>";
$list.="<th>Period</th>";
$list.="<th>Classcode</th>";
$list.="<th>Room</th>";
$list.="<th>Teacher</th>";
$list.="<th>Days</th>";
#loop through each row
while( $row = mysql_fetch_array($rs) )
{
$list .= "<tr>";
$list .= "<td>".$row["studentid"]."</td>";
$list .= "<td>".$row["period"]."</td>";
$list .= "<td>".$row["classcode"]."</td>";
$list .= "<td>".$row["room"]."</td>";
$list .= "<td>".$row["teacherlname"]."</td>";
$list .= "<td>".$row["days"]."</td>";
$list .= "</tr>";
}
$list .= "</table>";
#write out the list
echo($list);
?>
</body>
</html>