I am getting the following error message:
Notice: Undefined index: timein in time.php on line 42 Notice: Undefined index: timeout in time.php on line 45
Here is my code:
if (isset($_POST['submit'])) {
$name = $_POST['name'];
$querytimeout = mysql_query("
SELECT timein
FROM studentInfo
WHERE name = '$name'
ORDER BY time DESC
LIMIT 1,1
")
or die("Error querying database ".mysql_error());
$querytimein = mysql_query("
SELECT timeout
FROM studentInfo
WHERE name = '$name'
ORDER BY time DESC
LIMIT 1
")
or die("Error querying database ".mysql_error());
while($minutestimein = mysql_fetch_array($querytimein)){
$ltimein = $minutestimein['timein'];
}
while($minutestimeout = mysql_fetch_array($querytimeout)){
$ltimeout = $minutestimeout['timeout'];
}
$timegone = $ltimein - $ltimeout;
echo $timegone;
}
The problem is that mysql_fetch_array() isn't making timein or timeout an element of the array $minutestimein.
If you compare your queries to the fields that they are looking up, they don't match.
In the first query you select only
timeoutyet you try to reference$minutestimein['timein']. You do the opposite in the second query.