2017-06-14 9 views
0

index.phpの更新テーブルのタブデータを更新する方法は?

<div class="tab"> 
    <button class="tablinks" onclick="openCity(event, 'Engineering')">Engineering</button> 
    <button class="tablinks" onclick="openCity(event, 'LAW')">LAW</button> 
</div> 

<div id="Engineering" class="tabcontent"> 
    <table class="items"> 
     <tr> 
      <th>State</th> 
      <th>College Name</th> 
     </tr> 
      <?php 
       $query = "select * from college where field = 'engineering'"; 
       $show = mysqli_query($link,$query); 
       while ($fetch = mysqli_fetch_array($show)) 
       { 
      ?> 
      <tr> 
       <td><?php echo $fetch['state']?></td> 
       <td><?php echo $fetch['college_name']?></td> 
       <td> 
        <a href="edit.php?id=<?php echo $fetch['id']; ?>">edit</a> 
       </td> 
      </tr> 
      <?php  
       } 
      ?> 
    </table> 
</div> 
<div id="Law" class="tabcontent"> 
    <table class="items"> 
     <tr> 
      <th>State</th> 
      <th>College Name</th> 
     </tr> 
      <?php 
       $query = "select * from college where field = 'law'"; 
       $show = mysqli_query($link,$query); 
       while ($fetch = mysqli_fetch_array($show)) 
       { 
      ?> 
      <tr> 
       <td><?php echo $fetch['state']?></td> 
       <td><?php echo $fetch['college_name']?></td> 
       <td> 
        <a href="edit.php?id=<?php echo $fetch['id']; ?>">edit</a> 
       </td> 
      </tr> 
      <?php  
       } 
      ?> 
    </table> 
</div> 

このコードで个人设定

<?php 
if(isset($_POST['update'])) 
{ 
    $college_name = $_POST['colleges']; 
    $state = $_POST['state']; 
    $sqli = "update college set college_name = '$college_name', state = '$state' where id = '$id'"; 
    $results = mysqli_query($link,$sqli); 
    if($result == true) 
    { 
     $msg .= "<p style='color:green;'>Your data update successfully</p>"; 
    } 
    else 
    { 
     $msg .= "<p style='color:red;'>Errror!</p>"; 
    } 
} 
?> 
<form method="POST" enctype="multipart/form-data" > 
    <select name="state" id="state"> 
     <option value="<?php echo $stateid; ?>"><?php echo $statename; ?></option> 
     <option value="">Select State</option> 
     <?php 
     $sql = "select * from statemaster"; 
     $result = mysqli_query($link,$sql); 
     while($row = mysqli_fetch_array($result)) 
     { 
     echo "<option value=".$row['stateid'].">".$row['statename']."</option>"; 
     } 
     ?> 
    </select> 

    <select name="colleges" id="colleges"> 
     <option value="<?php echo $college_name; ?>"><?php echo $college_name; ?></option> 
     <option value="">Select College</option> 
    </select> 

    <button type="submit" name='update' id='update'>update</button> 
</form> 

私はそれは私がURLと実行更新クエリからIDを取得个人设定ページに移動します編集ボタンをクリックしたときテーブル大学を更新した後、データは更新されますが、私が編集ページからindex.phpページに移動すると、データは同じままですが、データベースの更新データがそこにあります。では、どうすればこの問題を解決できますか?

ありがとうございました

+0

どこ編集フォームがある: のように、変数であるindex.phpを呼び出してみては?更新クエリは機能しますか? –

+0

はい、@Fairy Dancer – omkara

+0

は明らかにそれについて説明していません。 http://chat.stackoverflow.com/rooms/146504/codeigniter –

答えて

0

キャッシングを確認してください。 index.phpの内容を取得するためにブラウザがサーバにアクセスしていない可能性があります。

<a href="index.php?<?=microtime()?>">Home</a>

+0

また、ブラウザでキャッシュを無効にすることもできます。 –

関連する問題