mysql - How to use OR operator in PHP? -


i have code in check variable value , try applying or operator failed. file have edit code. in scenario use 4 submit button like save, submit, approve , re-submit. on edit file start session , apply condition if there user show save , submit button if there manager show approve , re-submit button. on manager condition want apply if condition if previous status approve show re-submit button, if previous status save or submit show both approve , re-submit button

below code

<?php include ("session1.php"); ?> <?php     require 'database.php';     $id = null;     if ( !empty($_get['id'])) {         $id = $_request['id'];     }      if ( null==$id ) {         header("location: index.php");     }      //------------------------------------------update--------------------------------      if ( !empty($_post)) { $editor1 =mysql_real_escape_string(trim($_post['editor1'])); $editor2 =mysql_real_escape_string(trim($_post['editor2'])); $editor3 =mysql_real_escape_string(trim($_post['editor3'])); $editor4 =mysql_real_escape_string(trim($_post['editor4'])); $editor5 =mysql_real_escape_string(trim($_post['editor5'])); $editor6 =mysql_real_escape_string(trim($_post['editor6'])); $editor7 =mysql_real_escape_string(trim($_post['editor7'])); $editor8 =mysql_real_escape_string(trim($_post['editor8'])); $editor9 =mysql_real_escape_string(trim($_post['editor9'])); $editor10 =mysql_real_escape_string(trim($_post['editor10'])); if($_post['submit'] == "submit"){ $status=$_post['submit'];}  if($_post['submit'] == "save"){ $status=$_post['submit'];}   if($_post['submit'] == "approve"){ $status=$_post['submit'];}  if($_post['submit'] == "re-submit"){ $status=$_post['submit'];}  $valid = true;         if ($valid) {             $pdo = database::connect();             $sql = "update test1  set editor1 ='$editor1', editor2 ='$editor2', editor3 ='$editor3',                                         editor4 ='$editor4', editor5 = '$editor5', editor6 ='$editor6',                                         editor7 ='$editor7', editor8 ='$editor8', editor9 ='$editor9',                                         editor10 ='$editor10', status='$status'  id ='$id'";             $q = $pdo->prepare($sql);             $q->execute(array($editor1,$editor12,$editor3,$editor4,$editor5,$editor6,$editor7,$editor8,$editor9,             $editor10,$status,$id));             database::disconnect();             header("location: index.php");         } }     else {            }      $con=mysqli_connect("localhost","root","","pacra1");           $id2 = $_get['id'];         $sql = "select * test1 id='$id2'";              $result=mysqli_query($con,$sql);              $row= (mysqli_fetch_array($result,mysqli_assoc));  $editor1 =($row['editor1']); $editor2 =($row['editor2']); $editor3 =($row['editor3']); $editor4 =($row['editor4']); $editor5 =($row['editor5']); $editor6 =($row['editor6']); $editor7 =($row['editor7']); $editor8 =($row['editor8']); $editor9 =($row['editor9']); $editor10 =($row['editor10']); $status =($row['status']);      ?>  <!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <title>untitled document</title> <link rel="stylesheet" type="text/css" href="newstyles.css"> <link rel="stylesheet" href="../../jqwidgets/styles/jqx.base.css" type="text/css" />   <link rel="stylesheet" href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">  <script src="//code.jquery.com/jquery-1.10.2.js"></script> <script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script>  <script type="text/javascript" src="../../scripts/jquery-1.11.1.min.js"></script>  <script type="text/javascript" src="../../scripts/demos.js"></script>  <script type="text/javascript" src="../../jqwidgets/jqxcore.js"></script>  <script type="text/javascript" src="../../jqwidgets/jqxbuttons.js"></script>  <script type="text/javascript" src="../../jqwidgets/jqxscrollbar.js"></script>  <script type="text/javascript" src="../../jqwidgets/jqxlistbox.js"></script>  <script type="text/javascript" src="../../jqwidgets/jqxdropdownlist.js"></script>  <script type="text/javascript" src="../../jqwidgets/jqxdropdownbutton.js"></script>  <script type="text/javascript" src="../../jqwidgets/jqxcolorpicker.js"></script>  <script type="text/javascript" src="../../jqwidgets/jqxwindow.js"></script>  <script type="text/javascript" src="../../jqwidgets/jqxeditor.js"></script>  <script type="text/javascript" src="../../jqwidgets/jqxtooltip.js"></script>  <script type="text/javascript" src="../../jqwidgets/jqxcheckbox.js"></script>  </head>  <body>   <script type="text/javascript">         $(document).ready(function () {             $('#editor1').jqxeditor({tools: 'bold italic underline | left center right'             });              $('#editor2').jqxeditor({tools: 'bold italic underline | left center right'             });              $('#editor3').jqxeditor({tools: 'bold italic underline | left center right'             });              $('#editor4').jqxeditor({              });               $('#editor5').jqxeditor({tools: 'bold italic underline | left center right'             });             $('#editor6').jqxeditor({              });             $('#editor7').jqxeditor({tools: 'bold italic underline | left center right'             });             $('#editor8').jqxeditor({tools: 'bold italic underline | left center right'             });             $('#editor9').jqxeditor({tools: 'bold italic underline | left center right'             });             $('#editor10').jqxeditor({tools: 'bold italic underline | left center right'             });             $('#editor11').jqxeditor({             });          });     </script>      <div style="margin-top: 10px; width: 800px">      <div style=" margin:auto; width:60px; height:auto; align: middle">     <img src="image/pacra_logo.png" alt="logo">     </div>     <div style="margin:auto; width:auto; text-align:center; font-family:'times new roman', times, serif; font-variant: small-caps; font-size:20px; font-weight:bold">     pakistan credit rating agency limited      <hr></div>     <form action="edit.php?id=<?php echo $id; ?>" method="post" >                  <div style="width: 30%; float:left; line-height:0.5" contenteditable="true"><textarea name="editor1" id="editor1"><?php echo(nl2br($editor1));?></textarea>                 </div>                  <div style="clear: both;"></div>            <div style=" margin-top:30px; width:35%; float:left; font-family:'times new roman', times, serif; text-align:left; font-size:14px; line-height:0.5" contenteditable="true"><textarea name="editor2" id="editor2"><?php echo(nl2br($editor2));?></textarea></div>             <div style=" margin-top:30px; margin-left:220px; width:35%; float:left; font-family:'times new roman', times, serif; text-align:right; font-size:14px; line-height:0.5" contenteditable="true"><textarea name="editor3" id="editor3"><?php echo (nl2br($editor3));?></textarea></div>              <div style="clear: both;"></div>           <div style="margin-top:40px; margin-right:auto; width:auto; font-family:'times new roman', times, serif; text-align:center; font-variant:small-caps; font-size:18px; font-weight:bold; line-height:0.5" contenteditable="true"><textarea name="editor4" id="editor4"><?php echo(nl2br($editor4));?></textarea></div>          <div style=" margin-top:20px; width:20%; float:left; font-family:'times new roman', times, serif; text-align:left; font-size:16px; line-height:0.5" contenteditable="true"><textarea name="editor5" id="editor5"> <?php echo(nl2br($editor5));?></textarea></div>       <div style="clear: both;"></div>     <div style="margin-top: 10px; width: 800px; text-align:justify; font-family:'times new roman', times, serif; font-size:14px; line-height:0.5" contenteditable="true"><textarea name="editor6" id="editor6"><?php echo (nl2br($editor6));?></textarea></div>      <div style="margin-top:30px; width:auto; float:left; text-align:left; font-family:'times new roman', times, serif; font-size:16px" contenteditable="true"><textarea name="editor7" id="editor7"><?php echo(nl2br($editor7));?></textarea></div>     <div style="clear: both;"></div>     <div style="margin-top:100px; width:auto; float:left; text-align:left; font-family:'times new roman', times, serif; font-size:16px; font-variant:small-caps" contenteditable="true"><textarea name="editor8" id="editor8"><?php echo (nl2br($editor8));?></textarea></div> <div style="clear: both;"></div>     <div style="margin:auto; width:auto; float:left; text-align:left; font-family:'times new roman', times, serif; font-size:16px;" contenteditable="true"><textarea name="editor9" id="editor9"><?php echo(nl2br($editor9));?></textarea></div>         <div style="clear: both;"></div>     <div style="margin-top:40px; width:auto; height:30px float:left; text-align:left; font-family:'times new roman', times, serif; font-size:16px;" contenteditable="true">     <textarea name="editor10" id="editor10"><?php echo(nl2br($editor10));?></textarea>     </div>     <div style="margin-top:100px">     <?php   if($_session['username']=='user') { ?>     <input type="submit" name="submit" value="save">     <input type="submit" name="submit" value="submit"> <?php         }     if($_session['username']=='manager') {     $_post['submit']="";  if($_post['submit'] == "save" || "submit")     { ?>     <input type="submit" name="submit" value="approve">     <input type="submit" name="submit" value="re-submit">  <?php        }     }     else     { ?> <input type="submit" name="submit" value="re-submit"> <?php     }     ?>       </div>     </form> <div style="clear: both;"></div>     <div style="margin-top:70px; width:800px; float:left; text-align:center; font-family:'times new roman', times, serif; font-size:18px;">     <hr>  <strong>awami complex fb-1, usman block, new garden town, lahore-54600, pakistan</strong>    </br>pabx: 92(42)35869507 fax: 92(42)35830425 email: pacra@pacra.com   </br>www.pacra.com     </div>     </div> </body> </html> 

here code in face problem

<?php   if($_session['username']=='user') { ?>     <input type="submit" name="submit" value="save">     <input type="submit" name="submit" value="submit"> <?php         }     if($_session['username']=='manager') {     $_post['submit']="";  if($_post['submit'] == "save" || "submit")     { ?>     <input type="submit" name="submit" value="approve">     <input type="submit" name="submit" value="re-submit">  <?php        }     }     else     { ?> <input type="submit" name="submit" value="re-submit"> <?php     }     ?> 

you changing $_post['submit'] blank here. use code below.

remove line $_post['submit']="";

and change following to

<?php if($_session['username']=='manager') {      if($status == 'approve')     { ?>     <input type="submit" name="submit" value="re-submit">   <?php        }     else     { ?>     <input type="submit" name="submit" value="approve">     <input type="submit" name="submit" value="re-submit"> <?php     } } ?> 

Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

jquery - javascript onscroll fade same class but with different div -