2017-05-17 23 views
1

このページではisset関数が動作していませんが、別のページで動作しています 私はこれを作成しましたが、 「TはISSETが動作していないという理由だけで、テキストフィールドの値を取得します。

をここでコード

<?php 

$link = mysqli_connect("localhost","root","","officedb"); 

if(!$link) 
{ 
    echo"Not connected"; 
} 



$query = "SELECT * from items"; 

$result = mysqli_query($link,$query); 

    if(!$result) 
    { 
     echo"Not selected"; 
    } 



    if(isset($_POST["submit"])){ 

     echo "Hello"; 

    } 





?> 

<html> 


    <head> 

    <link rel="stylesheet" href="bootstrap-3.3.7-dist/css/bootstrap.min.css" > 


     <style> 

     .lb 
      { 
       background-color:#ADD8E6; 
       text-align: center; 
      } 

      .tl 
      { 
       text-align: center; 
      } 

      .disapp 
      { 
       display:none; 
      } 


     </style> 


     <script> 

      function divshow(){ 

       if(document.getElementById("entryname").value == "Name") 
        { 
         document.getElementById("nameed").style.display = 'block'; 
         document.getElementById("nsned").style.display = 'none'; 
         document.getElementById("quned").style.display = 'none'; 

        } 

       if(document.getElementById("entryname").value == "NSN/Part") 
        { 
         document.getElementById("nameed").style.display = 'none'; 
         document.getElementById("nsned").style.display = 'block'; 
         document.getElementById("quned").style.display = 'none'; 
        } 

       if(document.getElementById("entryname").value == "Quantity") 
        { 
         document.getElementById("nameed").style.display = 'none'; 
         document.getElementById("nsned").style.display = 'none'; 
         document.getElementById("quned").style.display = 'block'; 
        } 
      }; 


     </script> 





    </head> 


<body> 

    <div class="container"> 
    <table class="table table-hover"> 
    <tr> 
    <th class="lb" >Serial #</th> 
     <th class="lb" >Name</th> 
     <th class="lb" >NSN/part</th> 
     <th class="lb" >Quantity</th> 


<?php  
while($row = mysqli_fetch_array($result)) 
{ 
?> 

     <tr> 

      <td class="tl"><?php echo $row["S.NO"]; ?></td> 
      <td class="tl"><?php echo $row["Name"]; ?></td> 
      <td class="tl"><?php echo $row["NSN/Part"]; ?></td> 
      <td class="tl"><?php echo $row["Quantity"]; ?></td> 

     </tr> 

     <?php } ?> 

    </table> 




      <div class="border" style="border:1px solid grey;border-radius:6px;width:50%;margin-left:25%"> 

      <div class="row" style="margin-top:7%;"> 




       <div class="col-lg-4 col-lg-offset-3" style="margin-left:33%;"> 


      <form method="POST"> 

    <label>Select Item Serial #:</label> 

    <select class="form-control"> 



     <?php 

     $sql = "SELECT * from items"; 

     $newar=mysqli_query($link,$sql); 



     while($edit = mysqli_fetch_array($newar)){ ?> 

     <option value = <?php $edit[0]; ?> > <?php echo $edit[0]; } ?> </option> 



    </select> 

        <label style="margin-top:7%;">Select entry</label> 
    <select class="form-control" name="entryname" onchange="divshow()"> 
    <option value="Name">Name</option> 
    <option value="NSN/Part">NSN/Part</option> 
     <option value="Quantity">Quantity</option> 
    </select> 





       <div id="nameed" > 
     <input type="text" placeholder="Enter New Name" class="form-control" required name="namtxt" style="margin-top:16%;" /> 
     </div> 

     <div id="nsned" class="disapp" > 
     <input type="text" placeholder="Enter New NSN/Part" class="form-control" required name="nsntxt" style="margin-top:16%;" /> 
     </div> 

     <div id="quned" class="disapp" > 
     <input type="text" placeholder="Enter New Quantity" class="form-control" required name="quntxt" style="margin-top:16%;" /> 
     </div> 



       <div class="text-center"> 

       <input type="submit" name="submit" style="width:70%;margin-top:20%;" class="btn btn-success btn-md" value="Edit" /> 

       </div> 



        </form> 


       </div> 

        </div> 

       </div> 




    </div> 
</body> 






</html> 
+2

print_r($ _ POST)の場合は?配列を取得できますか? –

+0

はい配列を表示していますか?array() –

+0

空の配列またはサブミットされた配列ですか? –

答えて

1

ここでの問題は、この要求される分野であるが、それはフロントエンドで表示したときにあなたが提出されていませんフォームが送信されていないので、コードでJavaスクリプトエラーが発生するので、まずこれを解決してください

 <div id="nsned" class="disapp" > 
     <input type="text" placeholder="Enter New NSN/Part" class="form-control" required name="nsntxt" style="margin-top:16%;" /> 
     </div> 

     <div id="quned" class="disapp" > 
     <input type="text" placeholder="Enter New Quantity" class="form-control" required name="quntxt" style="margin-top:16%;" /> 
     </div> 
+0

このコードでは –

+0

を使っています。このコードではdisplay:none siteを使用していますので、最初にコードを外してください。 –

+0

助けてくれてありがとう –

関連する問題