i have a problem...
when the admin clicks on a certain row of data to edit, i will lock that row of data using the below queries:
$query = "UPDATE report SET Locked='1' WHERE ReportID='$_GET[ReportID]'";
$result5 = mysql_query($query) //process the sql statement into a result
//if there is a problem with the statement it will print the line couldnt execute query
or die ("couldn't execute query5.");
if some1 trys to click on the same row of data now, it will appear a MESSAGE page saying that the data is currently being edited.
when the admin trys to click on a drop down to change the value of the data. i have 2 drop downs and they are dynamically related using javascript
like when the admin clicks on an option in drop down A, the page RELOADS and the options available in drop down B will appear based on the option selected in drop down A.
the problem then arises, when the page RELOADS after the admin selects the drop down, the admin is directed to the MESSAGE page.
how can i make the admin stay in the editing page after the page reloads?
i have a locked column by default is set to 0.
logic problem causing a problem after reloading
Moderator: General Moderators
-
ljudgementl
- Forum Newbie
- Posts: 2
- Joined: Tue Nov 29, 2005 9:33 pm
-
ljudgementl
- Forum Newbie
- Posts: 2
- Joined: Tue Nov 29, 2005 9:33 pm
i think i noe where the fault lies
Code:
<?
//this sql statement select the value of the lock field of the selected userid
$query = "SELECT Locked FROM report WHERE ReportID='$_GET[ReportID]'";
$result4 = mysql_query($query) //process the sql statement into a result
//if there is a problem with the statement it will print the line couldnt execute query
or die ("couldn't execute query4.");
//it gets the value of the result and store it in $lock. mysql_result is more suitable if the
//return result is only of 1 value
$lock = mysql_result($result4,0);
if($lock==0)
{
$query = "UPDATE report SET Locked='1' WHERE ReportID='$_GET[ReportID]'";
$result5 = mysql_query($query) //process the sql statement into a result
//if there is a problem with the statement it will print the line couldnt execute query
or die ("couldn't execute query5.");
?>
<html>....
<SCRIPT language=JavaScript>
function reload(form)
{
var val=form.AircraftType.options[form.AircraftType.options.selectedIndex].value;
self.location='edit_report.php?ReportID=<? echo $_GET['ReportID']; ?>&ReportedBy=<? echo $_GET['ReportedBy']; ?>&AircraftType=' + val ;
}
</script>
<body>....................................
...............................................
...............................................
</body>
</html>
<?
}
else
{
header("Location: restrict_data_error.php");
}
?>
i did the if else statement so that if the row of data is not locked(locked=0), i will lock the data and display the page.
else if the data is locked(locked=1) means that some1 is editing the data it will direct the user to the MESSAGE.
but i realise now that once the page RELOADS, it does the comparing again. since b4 the page reloads, it already is locked. so it will redirect the user to the MESSAGE instead of displying the page.
crap lol could some1 help? really stuck =D
Code:
<?
//this sql statement select the value of the lock field of the selected userid
$query = "SELECT Locked FROM report WHERE ReportID='$_GET[ReportID]'";
$result4 = mysql_query($query) //process the sql statement into a result
//if there is a problem with the statement it will print the line couldnt execute query
or die ("couldn't execute query4.");
//it gets the value of the result and store it in $lock. mysql_result is more suitable if the
//return result is only of 1 value
$lock = mysql_result($result4,0);
if($lock==0)
{
$query = "UPDATE report SET Locked='1' WHERE ReportID='$_GET[ReportID]'";
$result5 = mysql_query($query) //process the sql statement into a result
//if there is a problem with the statement it will print the line couldnt execute query
or die ("couldn't execute query5.");
?>
<html>....
<SCRIPT language=JavaScript>
function reload(form)
{
var val=form.AircraftType.options[form.AircraftType.options.selectedIndex].value;
self.location='edit_report.php?ReportID=<? echo $_GET['ReportID']; ?>&ReportedBy=<? echo $_GET['ReportedBy']; ?>&AircraftType=' + val ;
}
</script>
<body>....................................
...............................................
...............................................
</body>
</html>
<?
}
else
{
header("Location: restrict_data_error.php");
}
?>
i did the if else statement so that if the row of data is not locked(locked=0), i will lock the data and display the page.
else if the data is locked(locked=1) means that some1 is editing the data it will direct the user to the MESSAGE.
but i realise now that once the page RELOADS, it does the comparing again. since b4 the page reloads, it already is locked. so it will redirect the user to the MESSAGE instead of displying the page.
crap lol could some1 help? really stuck =D