Jump to content

php MYSQL HELP


adavison2

Recommended Posts

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

Link to comment
Share on other sites

 

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.