
October 16th, 2004, 12:15 AM
|
 |
I'm Internet Famous
|
|
Join Date: Jan 2003
Location: Toronto, Canada
Posts: 2,890
 
Time spent in forums: 1 Week 16 h 14 m 9 sec
Reputation Power: 8
|
|
this line: if ($rowStatus > $status)
$rowStatus is an array... you need to reference a specific field...
I'd recommend modifying your query to read select max(Status) as status from StatusTable where Mapnumber = '$mapnumber' then changing that line to reference the proper element... if ($rowStatus['status'] > $status)
also, is $mapnumber a number? perhaps it shouldn't be in quotes in your query.
um, I was editting your code for my own readability, and there seems to be a mix up of brackets... what's the bracket above the IF statement I mentioned above?
This code is different than the code you posted as that INSERT statement will ALWAYS run... I assume you dont intend it to do so... but why not correct my interpretation of your code so it reads the way you want it to...
My updated version of your code
PHP Code:
if (isset($_POST['status'])) {
$query = "SELECT MAX(Status) AS status FROM StatusTable WHERE Mapnumber = '$mapnumber'";
$rs = mysql_query($query) or die(mysql_error());
$rowStatus = mysql_fetch_row($rs);
if ($rowStatus['status'] > $status) {
echo "The Status entered should not be less than '$rowStatus!'";
}
} else {
$timestamp = $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());
Try the code again... if you still get an error, or unexpected results, try telling us an example of the results and perhaps what they should be.
|