Basically a client has an admin area that allows a manager to update a report that is already in the database, which is fine, but what he wants me to do is if the report fails to be updated because it has a zero in one of the fields, then basically it returns to a page called page1_Man.php unchanged, maybe even an alert pops up to let them know it hasnt been updated and when the ok button is clicked on the alert, then it moves.
This is that code:
Code: Select all
$sql = mysql_query("UPDATE hazzard SET Name='$name', Employerofperson='$employer', Contactphone='$telephone', NearMissDetails='$detail', Anyimmediateactions='$action', HazardorNearMiss='$hazardornearmiss', Primarycause='$primarycause3', Primarycause2='$primarycause1', Rottcause='$rootcause', Rottcause2='$primarycause2', Behaviours='$behaviours', PotentialOutcome='$potentialoutcome', Likelihood='$likelihood', Comments='$comments', report_Completed_By='$completedByManager' WHERE UniqueIdentifier='$report_ID' AND HazardorNearMiss !='0' AND Primarycause !='0' AND Primarycause2 !='0' AND Rottcause !='0' AND Rottcause2 !='0' AND Behaviours !='0' AND PotentialOutcome !='0' AND Likelihood !='0'") or die ("You may have not selected all the options in the drop downs, click 'Back' to return and try again.");
Then I have a very similar scenario but this time slightly different.
This time the manager is selecting a number of reports to export to a csv file, and basically where Im checking if any of the reports contain a zero is doesnt get added to the session with the others but instead moves to a different script that updates that report by making some of the fields empty before returning it to the database.
Code: Select all
$x="select Name, Employerofperson, Contactphone, Location, DATE_FORMAT(DateOccured, '%e-%c-%Y %H:%i') as DateOccurred, ProductionZone, REPLACE(REPLACE(REPLACE(REPLACE(NearMissDetails, CHAR(13),' '), CHAR(10),' '), ' ',' '), ' ', ' ') as NearMissDetails, REPLACE(REPLACE(REPLACE(REPLACE(Anyimmediateactions, CHAR(13),' '), CHAR(10),' '), ' ',' '), ' ', ' ') as Anyimmediateactions, HazardorNearMiss, Primarycause, Rottcause, Behaviours, PotentialOutcome, Likelihood, REPLACE(REPLACE(REPLACE(REPLACE(Comments, CHAR(13),' '), CHAR(10),' '), ' ',' '), ' ', ' ') as Comments, PersonsMostLikelyInjured, CloseDate, HighPotentialIncident, HPIInvestigatedBy, BUHSELeader, BUSectorLeader, HPIInvestigationConclusion, HPIBriefingNoteRef, HPIInvestigationCloseOutDate FROM hazzard WHERE ".$sqlstar." AND HazardorNearMiss !='0' AND Primarycause !='0' AND Rottcause !='0' AND Behaviours !='0' AND PotentialOutcome !='0' AND Likelihood !='0' ORDER by DateOccured ASC";
$_SESSION['currentQuery5'] = $x;
I hope that makes sense