Forum Moderators: coopster
if (isset($_POST['status']))
{
$query = "select max(Status) from StatusTable where Mapnumber = '$mapnumber'";
$rs = mysql_query($query) or die(mysql_error());
$rowStatus = mysql_fetch_row($rs);
{
if ($rowStatus > $status)
{
echo "The Status entered should not be less than '$rowStatus!'";
}
}
else$timestamp = "{$_POST['fromYear']}-{$_POST['fromMonth']}-{$_POST['fromDay']}";
$sql= "insert into StatusTable (ActDate, PIN, Activity, RegHours, Status, Mapnumber) values ('" . $timestamp . "','" . $_SESSION['username'] . "','" . $_POST['activity'] . "','" . number_format($_POST['work_hours'], 2) . "','" . $_POST['status'] . "','" . $_POST['mapnumber'] . "')";
mysql_query($sql) or die('error making query: ' . mysql_error());
$rowStatus = mysql_fetch_row($rs);
I assume it will only select a single row with a max() so try the same line this way
if ($rowStatus = mysql_fetch_row($rs));
only a guess since I see an opening brace after it and nothing that needs a brace, I would think you should have a parse error actually
another thing is I think you need a brace after
else {
and then one at the end of the code you pasted unless there is something more in the else
if (isset($_POST['status']))
{
$query = "select Status from StatusTable where Mapnumber = '$mapnumber'";
$rs = mysql_query($query) or die(mysql_error());
$rowStatus = mysql_fetch_row($rs);
{
if ($rowStatus[0] > $_POST['status'])
{
echo "The Status entered should not be less than '$rowStatus[0]!'";
}
else
$timestamp = "{$_POST['fromYear']}-{$_POST['fromMonth']}-{$_POST['fromDay']}";$sql= "insert into StatusTable (ActDate, PIN, Activity, RegHours, Status, Mapnumber) values ('" . $timestamp . "','" . $_SESSION['username'] . "','" . $_POST['activity'] . "','" . number_format($_POST['work_hours'], 2) . "','" . $_POST['status'] . "','" . $_POST['mapnumber'] . "')";
mysql_query($sql) or die('error making query: ' . mysql_error());
}
}
And also I am facing another problem which is if the user logs out and decided to login again therefore the default should not be 7.5 but it should be the remaining number of hours for that date.