2016-03-21 23 views
-1

veri html tablo zaten editlocator.php kadar gösteriyor oluşturan yanlış alanında gösterir ancak veriler yanlış alanda gösteriliyorsaDüzenleme html veri tablosu, Veri

enter image description here

editest .php

<?php 

include('dbconn.php'); 

$query = "SELECT * FROM tbl_locators WHERE accholder_ID='1'"; 
$result = mysqli_query($con, $query); 

?> 

    <!DOCTYPE html> 
    <html> 
     <head> 
       <meta charset="UTF-8"> 
      <meta name="viewport" content="width=device-width, initial-scale=1.0"> 
      <link rel="stylesheet" href="/Cisu/css/footable.core.css"> 
      <link rel="stylesheet" href="/Cisu/css/footable.metro.css"> 
      <script src="https://code.jquery.com/jquery-1.11.3.js"></script> 
      <script src="/Cisu/javascript/jquery/footable.js"></script> 
      <script src="/Cisu/javascript/jquery/footable.paginate.js"></script> 
      <script src="/Cisu/javascript/jquery/footable.filter.js"></script> 
      <link rel="stylesheet" href="/Cisu/css/search.css" type="text/css" media="screen"/> 
      <link rel="stylesheet" href="/Cisu/css/footable.editable-1.0.css" type="text/css" media="screen"/> 
     </head> 
     <body> 


      <div id="header"> 
       <img src="/Cisu/images/sbma.png" class="logo" id="logo"></img> 
       <a style = "float:left;">Account Settings</a> 
       <a href="#">Home</a> 
       <a href="#">Locators</a> 
      </div> 
      <div id="navigation"> 
          <ul class="ul-sidebar"> 
        <li class="li-sidebar"> 
         <a class="active">View Locators</a> 
        </li> 
       </ul> 

      <form class="form-style-1"> 

      <ul class="ul-sidebar"> 
      <li class="li-sidebar"> <label class="header-label">Company Name:</label> 
       <input type="text" id="filter"/></li> 
    </select> 
      </ul> 
      </form> 

      </div> 
      <div id="section"> 
       <table class="footable" data-page-size="3" data-filter="#filter" data-filter-minimum="4" data-first-text="FIRST" data-next-text="NEXT" data-previous-text="PREVIOUS" data-last-text="LAST"> 
       <thead> 
       <tr> 
        <th>ID</th> 
        <th>Company Name</th> 
        <th>Nationality</th> 
        <th>Primary Address</th> 
        <th>Industry Code</th> 
        <th>TIN</th> 
        <th>Status</th> 
        <th>Employees</th> 
        <th>Account Holder ID</th> 
        <th>EDIT</th> 
       </tr> 
       </thead> 

       <tbody> 

        <!-- populate table from mysql database --> 
       <?php 
while ($row1 = mysqli_fetch_array($result)):; 
?> 
       <tr> 
        <td><?php 
    echo $row1['locators_ID']; 
?></td> 
        <td><?php 
    echo $row1['locators_CompanyName']; 
?></td> 
        <td><?php 
    echo $row1['locators_Nationality']; 
?></td> 
        <td><?php 
    echo $row1['locators_PrimaryAddress']; 
?></td> 
        <td><?php 
    echo $row1['locators_IndustryCode']; 
?></td> 
        <td><?php 
    echo $row1['locators_TIN']; 
?></td> 
        <td><?php 
    echo $row1['locators_Status']; 
?></td> 
        <td><?php 
    echo $row1['locators_Employees']; 
?></td> 
        <td><?php 
    echo $row1['accholder_ID']; 
?></td> 
        <?php 
    echo '<td><a href="editlocator.php?locators_ID=' . $row1['locators_ID'] . '">Edit</a></td>'; 
?> 

       </tr> 
       <?php 
endwhile; 
?> 

       </tbody> 

       <!-- the pagination --> 
       <!-- hide-if-no-paging = hide the pagination control --> 
       <tfoot class="hide-if-no-paging"> 
       <td colspan="9"> 
        <div class="pagination"></div> 
       </td> 
       </tfoot> 
      </table> 
     <script type="text/javascript"> 

      $(document).ready(function(){ 

       $('.footable').footable(); 

      }); 

     </script> 

      </div> 
      <div id="footer"> 
       S.B.M.A Centralized Information System 
      </div> 
     </body> 
    </html> 

editlocator.php

<?php 

include("dbconn.php"); 

function renderForm($id = '', $accid = '', $companyname = '', $nationality = '', $primaryaddress = '', $industrycode = '', $tin = '', $status = '', $employees = '') 
{ 

?> 

<html> 
    <head> 
     <link rel="stylesheet" href="css/add.css" type="text/css" media="screen"/> 
     <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> 
     <Title> 
     EDIT 
     </title> 
    </head> 
    <body> 
     <div id="header"> 
      <img src="images/sbma.png" class="logo" id="logo"></img> 
      <a style = "float:left;">Account Settings</a> 
      <a href="AdminMenu.php">Home</a> 
      <a href="DeptMenu.php">Department</a> 
     </div> 
     <div id="navigation"> 
        <form class="form-style-1" action="" method="post"> 
      <ul> 
       <fieldset class="fieldset-company"> 
       <input type="hidden" name="locators_ID" value="<?php 
    echo $id; 
?>" /> 
       <p>ID: <?php 
    echo $id; 
?></p> 
       <input type="hidden" name="accholder_ID" value="<?php 
    echo $accid; 
?>" /> 
       <p>Account ID: <?php 
    echo $accid; 
?></p>    
        <li> 
         <label>Company Name</label> 
         <input type='text' name='companyname' id='companyname' maxlength="50" value="<?php 
    echo $companyname; 
?>"/> 
        </li> 

        <li> 
         <label>Nationality</label> 
         <input type='text' name='nationality' id='nationality' maxlength="50" value="<?php 
    echo $nationality; 
?>"/> 
        </li> 
        <li> 
         <label>Primary Address</label> 
         <input type='text' name='primaryaddress' id='primaryaddress' maxlength="50" value="<?php 
    echo $primaryaddress; 
?>"/> 
        </li> 

        <li> 
         <label>Industry Code:</label> 
         <input type='text' name='industrycode' id='industrycode' maxlength="50" value="<?php 
    echo $industrycode; 
?>"/> 
        </li> 
        <li> 
         <label>TIN:</label> 
         <input type='text' name='tin' id='tin' maxlength="50" value="<?php 
    echo $tin; 
?>"/> 
        </li> 
        <li> 
         <label>Status:</label> 
         <input type='text' name='status' id='status' maxlength="50" value="<?php 
    echo $status; 
?>"/> 
        </li> 
        <li> 
         <label>Employees:</label> 
         <input type='text' name='employees' id='employees' maxlength="50" value="<?php 
    echo $employees; 
?>"/> 
        </li> 
        </fieldset> 

         <li> 
         <input type='Submit' name='Submit' value='Submit' /> 
         </li> 
       </ul> 
     </div> 
     <div id="section"> 


      </form> 
     </div> 
     <div id="footer"> 
    S.B.M.A Centralized Information System 
    </div> 
    </body> 
</html> 

<?php 
} 

// if the 'id' variable is set in the URL, we know that we need to edit a record 
if (isset($_GET['locators_ID'])) { 
    // if the form's submit button is clicked, we need to process the form 
    if (isset($_POST['Submit'])) { 
     // make sure the 'id' in the URL is valid 
     if (is_numeric($_POST['locators_ID'])) { 
      // get variables from the URL/form 
      $id    = $_POST['locators_ID']; 
      $accid   = $row1['accholder_ID']; 
      $companyname = htmlentities($_POST['locators_CompanyName'], ENT_QUOTES); 
      $nationality = htmlentities($_POST['locators_Nationality'], ENT_QUOTES); 
      $primaryaddress = $_POST['locators_PrimaryAddress']; 
      $industrycode = htmlentities($_POST['locators_IndustryCode'], ENT_QUOTES); 
      $tin   = htmlentities($_POST['locators_TIN'], ENT_QUOTES); 
      $status   = $_POST['locators_Status']; 
      $employees  = htmlentities($_POST['locators_Employee'], ENT_QUOTES); 


      if ($stmt = $con->prepare("UPDATE tbl_locators SET locators_CompanyName = ?, locators_Nationality = ?, locators_PrimaryAddress=?, locators_IndustryCode =?, locators_TIN =?, locators_Status=?, locators_Employee =? 
WHERE locators_ID=?")) { 
       $stmt->bind_param("ssi", $id, $accid, $companyname, $nationality, $primaryaddress, $industrycode, $tin, $status, $employees); 
       $stmt->execute(); 
       $stmt->close(); 
      } 
      // show an error message if the query has an error 
      else { 
       echo "ERROR: could not prepare SQL statement."; 
      } 

      // redirect the user once the form is updated 
      header("Location: editest.php"); 
     } 
     // if the 'id' variable is not valid, show an error message 
     else { 
      echo "ID VARIABLE NOT VALID!"; 
     } 
    } 
    // if the form hasn't been submitted yet, get the info from the database and show the form 
    else { 
     // make sure the 'id' value is valid 
     if (is_numeric($_GET['locators_ID']) && $_GET['locators_ID'] > 0) { 
      // get 'id' from URL 
      $id = $_GET['locators_ID']; 

      // get the recod from the database 
      if ($stmt = $con->prepare("SELECT * FROM tbl_locators WHERE locators_ID=?")) { 
       $stmt->bind_param("i", $id); 
       $stmt->execute(); 

       $stmt->bind_result($id, $accid, $companyname, $nationality, $primaryaddress, $industrycode, $tin, $status, $employees); 
       $stmt->fetch(); 

       // show the form 
       renderForm($id, $accid, $companyname, $nationality, $primaryaddress, $industrycode, $tin, $status, $employees); 

       $stmt->close(); 
      } 
      // show an error if the query has an error 
      else { 
       echo "Error: could not prepare SQL statement"; 
      } 
     } 
     // if the 'locators_ID' value is not valid, redirect the user back to the view.php page 
     else { 
      header("Location: editest.php"); 
     } 
    } 
} 
?> 

Tablo Yapısı enter image description here

+0

'' Yarı-mamul ürünün kolon çıkarın. Bu bir ifade karakterinin sonu. Gerisi için, tüm kodunuzu gözden geçirmeniz gerekecek. –

+0

@ Fred -ii Onu kaldırdım ve hiçbir şey değişmedi –

+0

Eğer php biraz girintiye sahip olsaydı takip etmek çok daha kolay olurdu ... – Rasclatt

cevap

0

veritabanından iade edilen ne ayıklama. Beklediğiniz şey değilse, değişkenlerinize $ stmt-> bind_result değerlerinin hangi değerleri verdiğini öğrenmeniz gerekir. Sorgunuz tüm alanları döndürdüğü için tbl_locators tablonuzun yapısını kontrol edin.

$stmt->bind_result($id, $accid, $companyname, $nationality, $primaryaddress, $industrycode, $tin, $status, $employees); 
$stmt->fetch(); 

var_dump($accid); 

// show the form 
renderForm($id, $accid, $companyname, $nationality, $primaryaddress, $industrycode, $tin, $status, $employees); 
+0

dize (7) "Şirket" diyor, bu yüzden $ locators_companyname değerini döküyor kaza mı? –

+0

$ stmt-> bind_result tarafından ayarlanan değişkenlerin sırasını, tablonuzun yapısında görünen alanlara eşleştirmeyi deneyin. Bu, değişkenlerinize doğru değerleri atayacaktır. –

+0

Bunu denedim ve çalışıyor şimdi sorun şu anda bu güncellenmiyor –

İlgili konular