adavison2 Posted January 17, 2011 Share Posted January 17, 2011 Hi in new to php with a work colleague we have been designing a php/mysql reporting system for the school i work at but need a help with a bug teachers can update reports when they do the code pouplates the textareas with what is in the DB they can then make changes no problem but if two do it at the same time or one opens a reports goes makes a tea another opens the same report makes a changes updates report lets say Science then and then the other teacher comes bak makes a change to Maths it rewights the old science over the top of the new one the othe teacher did a little while ago In short can you make a php statment that onchange of textarea then include into the mysql update query if no change the dont include that in the mysql update query Quote Link to comment Share on other sites More sharing options...
leitning_strike Posted January 17, 2011 Share Posted January 17, 2011 Include the original text in a hidden input type and check whether the hidden input and textarea input match Quote Link to comment Share on other sites More sharing options...
adavison2 Posted January 17, 2011 Author Share Posted January 17, 2011 This is te query im useing at the moment $query = "INSERT INTO report (name,class,Sex,Reading_Effort,Reading_Progress,Reading_Target, Writing_Effort,Writing_Progress,Writing_Target,Maths_Effort,Maths_Progress,Maths_Target,Science,Topic,UPN) VALUES ('$name2','$class','$sex','$readingeffort','$readingprogress','$readingtarget', '$writingeffort','$writingprogress','$writingtarget','$mathseffort','$mathsprogress','$mathstarget','$science','$topic','$UPN')"; I can get the change by textarea onchange function to change a VAR to 1 what i need to figure out i if this VAR is 1 then INSERT INTO report what ever has been set to 1 Thank Quote Link to comment Share on other sites More sharing options...
the182guy Posted January 17, 2011 Share Posted January 17, 2011 Heres one option: In your db table that holds the reports, have a 'last_updated' field. Each time the report is updated, update last_updated to the current timestamp. Now, whenever you select a report to show on screen in the textarea, select the last_updated field aswell and include it in a hidden field on the form. When the form is submitted, run a query and check if the submitted last updated stamp matches the db last updated stamp, if it doesn't match then you know someone else has modified it since. You should have a last updated record anyway, even if you didn't need this check as you need to keep a paper trail of who has updated what and when incase of any problems. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.