如果语句正确,则更改字段


Change a field if a statement is correct

如果语句正确,如何将表中的字段(已完成)更改为是?

更新(代码顶部)

$sql="UPDATE Triage SET sceneaccident='$sceneaccident', notrequiretreatment='$notrequiretreatment', house='$house', recommendations='$recommendations', Prognosis='$Prognosis', CV='$CV', cervical='$cervical', heat='$heat', ice='$ice', lumbar='$lumbar', medication='$medication', posture='$posture', sport='$sport', given='$given' ,organs='$organs', deformity='$deformity', otherchanges='$otherchanges', receivingtreatment='$receivingtreatment', surgery='$surgery', Impression='$Impression', management='$management', ifyes='$ifyes', Rehabilitation='$Rehabilitation', Number='$Number', Psychological='$Psychological', diagnostic='$diagnostic', eyes='$eyes', burns='$burns', head='$head', symptoms='$symptoms', memory='$memory', scaring='$scaring', genitals='$genitals', dental='$dental', stomach='$stomach', directly='$directly', behalfclient='$behalfclient', investigations='$investigations', injuries='$injuries', duties='$duties', Wherepain='$Wherepain', pain='$pain', aggravates='$aggravates', eases='$eases', Movement='$Movement', neural='$neural', UnderstandNPRS='$UnderstandNPRS', NPRSassessment='$NPRSassessment', yourhobbies='$yourhobbies', hobbiesaffected='$hobbiesaffected', social='$social', activities='$activities', lifestyle='$lifestyle', avoiddriving='$avoiddriving', grip='$grip', flashbacks='$flashbacks', braking='$braking', past='$past', psychologically='$psychologically' WHERE Reference='$Reference'";
 $result=mysql_query($sql);
 // 
 while($rows=mysql_fetch_array($result)){
 echo '<a href="update.php?Reference='.$rows['Reference'].' ">update test</a>';
 }
// 
if (!$_REQUEST['sceneaccident'] || !$_REQUEST['notrequiretreatment'] || !$_REQUEST['house'] || !$_REQUEST['recommendations'] || !$_REQUEST['Prognosis'] || !$_REQUEST['CV'] || !$_REQUEST['cervical'] || !$_REQUEST['heat'] || !$_REQUEST['ice'] || !$_REQUEST['lumbar'] || !$_REQUEST['medication'] || !$_REQUEST['posture'] || !$_REQUEST['sport'] || !$_REQUEST['given'] || !$_REQUEST['organs'] || !$_REQUEST['deformity'] || !$_REQUEST['otherchanges'] || !$_REQUEST['receivingtreatment'] || !$_REQUEST['surgery'] || !$_REQUEST['Impression'] || !$_REQUEST['management'] || !$_REQUEST['ifyes'] || !$_REQUEST['Rehabilitation'] || !$_REQUEST['Number'] || !$_REQUEST['Psychological'] || !$_REQUEST['diagnostic'] || !$_REQUEST['eyes'] || !$_REQUEST['burns'] || !$_REQUEST['head'] || !$_REQUEST['symptoms'] || !$_REQUEST['memory'] || !$_REQUEST['scaring'] || !$_REQUEST['genitals'] || !$_REQUEST['dental'] || !$_REQUEST['stomach'] || !$_REQUEST['directly'] || !$_REQUEST['behalfclient'] || !$_REQUEST['investigations'] || !$_REQUEST['injuries'] || !$_REQUEST['duties'] || !$_REQUEST['Wherepain'] || !$_REQUEST['pain'] || !$_REQUEST['aggravates'] || !$_REQUEST['eases'] || !$_REQUEST['Movement'] || !$_REQUEST['neural'] || !$_REQUEST['UnderstandNPRS'] || !$_REQUEST['NPRSassessment'] || !$_REQUEST['yourhobbies'] || !$_REQUEST['hobbiesaffected'] || !$_REQUEST['social'] || !$_REQUEST['activities'] || !$_REQUEST['lifestyle'] || !$_REQUEST['avoiddriving'] || !$_REQUEST['grip'] || !$_REQUEST['flashbacks'] || !$_REQUEST['braking'] || !$_REQUEST['past'] || !$_REQUEST['psychologically'] )
{
 echo ('You did not complete all of the required fields');
 echo "<BR>";
 //while($rows==mysql_fetch_array($result)){
 echo "<a href='update.php?Reference={$rows['Reference']}.'>update</a>'n";
 }
// } // end of while loop 
 else {
 echo "Successful";
 echo "<BR>";
 echo "<a href='list_records.php'>View result</a>";
 }
 ?> 

你的意思是SQL查询?

$conn = new PDO("mysql:host=$dbhost;dbname=$dbname",$dbuser,$dbpass);
if (!$_REQUEST['sceneaccident'] || !$_REQUEST['notrequiretreatment'] || !$_REQUEST['house'] || !$_REQUEST['recommendations'] || !$_REQUEST['Prognosis'] || !$_REQUEST['CV'] || !$_REQUEST['cervical'] || !$_REQUEST['heat'] || !$_REQUEST['ice'] || !$_REQUEST['lumbar'] || !$_REQUEST['medication'] || !$_REQUEST['posture'] || !$_REQUEST['sport'] || !$_REQUEST['given'] || !$_REQUEST['organs'] || !$_REQUEST['deformity'] || !$_REQUEST['otherchanges'] || !$_REQUEST['receivingtreatment'] || !$_REQUEST['surgery'] || !$_REQUEST['Impression'] || !$_REQUEST['management'] || !$_REQUEST['ifyes'] || !$_REQUEST['Rehabilitation'] || !$_REQUEST['Number'] || !$_REQUEST['Psychological'] || !$_REQUEST['diagnostic'] || !$_REQUEST['eyes'] || !$_REQUEST['burns'] || !$_REQUEST['head'] || !$_REQUEST['symptoms'] || !$_REQUEST['memory'] || !$_REQUEST['scaring'] || !$_REQUEST['genitals'] || !$_REQUEST['dental'] || !$_REQUEST['stomach'] || !$_REQUEST['directly'] || !$_REQUEST['behalfclient'] || !$_REQUEST['investigations'] || !$_REQUEST['injuries'] || !$_REQUEST['duties'] || !$_REQUEST['Wherepain'] || !$_REQUEST['pain'] || !$_REQUEST['aggravates'] || !$_REQUEST['eases'] || !$_REQUEST['Movement'] || !$_REQUEST['neural'] || !$_REQUEST['UnderstandNPRS'] || !$_REQUEST['NPRSassessment'] || !$_REQUEST['yourhobbies'] || !$_REQUEST['hobbiesaffected'] || !$_REQUEST['social'] || !$_REQUEST['activities'] || !$_REQUEST['lifestyle'] || !$_REQUEST['avoiddriving'] || !$_REQUEST['grip'] || !$_REQUEST['flashbacks'] || !$_REQUEST['braking'] || !$_REQUEST['past'] || !$_REQUEST['psychologically'] ){
     echo ('You did not complete all of the required fields');
     echo "<BR>";
     //while($rows==mysql_fetch_array($result)){
     echo "<a href='update.php?Reference={$rows['Reference']}.'>update</a>'n";
 }
// } // end of while loop 
 else {             
         $sql = "UPDATE Triage 
                SET completed=?";
         $q = $conn->prepare($sql);
         $q->execute(array("yes"));
         echo "Successful";
         echo "<BR>";
         echo "<a href='list_records.php'>View result</a>";
 }
 ?>

MySQL 版本

$sql = "UPDATE Triage SET completed='yes'";

$result=mysql_query($sql);

注意* 使用 PDO 或 Mysqli 原因