0

私が何をする必要があるかを説明しましょう。下の画像は私のページです。CentOsサーバー上のmysqlに接続されており、phpもcentos上にあります。

  • 復元と削除があります。
  • データベースの値を更新するだけです。
  • 更新されると、復元または削除のいずれかに変更されます。
  • 私の問題は、クリックしたときに変更が正しく表示されないことです。ページをリロードする必要があります。
  • たとえば、(get を使用して) [削除] をクリックすると、データベースが更新され、それ自体が [復元] に変更されます。変更するための php コードがありますが、手動でページを更新する必要があります。
  • 私はphpヘッダーを試しました.Xamppでは動作しますが、何らかの理由で動作しません.

.

$page = $_SERVER['PHP_SELF'];
$sec = "0.001";
header("Refresh: $sec; url=$page")

また

header("Location: view.php");

ここに画像の説明を入力

<html>
  <head>
    <meta charset="UTF-8">
  <?php
include "library2.php";
include "delete.php";
printHeader(); // prints the logo
?>
  <title>
    View
  </title>
  <link rel="stylesheet" type="text/css" media="screen" href="styles.css">
  <nav>
    <ul>
      <li>
        <a href="add.php">
          Add
        </a>
      </li>

      <li>
        <a href="view.php">
          View
        </a>
      </li>
    </ul>
  </nav>
  </head>

  <body>
<?php
$link = connectMysql();
$sql_query = "SELECT * from inventory;";
$result = runQuery($link, $sql_query);      

if($_GET){
deleteRestoreItem($_GET['DeleteRestore']);

$page = $_SERVER['PHP_SELF'];
$sec = "0.001";
header("Refresh: $sec; url=$page");
}
?>
    <div id ="view">
    </br>
  </br>
</br>
<table >

  <th>
    ID
  </th>
  <th>
    Item Name
  </th>
  <th>
    Description
  </th>
  <th>
    Supplier Code
  </th>
  <th>
    Cost
  </th>
  <th>
    Selling Price
  </th>
  <th>
    Number On Hand
  </th>
  <th>
    Reorder Point
  </th>
  <th>
    Back Order
  </th>
  <th>
    Delete/Restore
  </th>
  <?php

while($row = mysqli_fetch_assoc($result))
{
?>
              <tr>
                <td>
                  <?php print $row['id']; ?>
                </td>
                <td>
                  <?php print $row['itemName']; ?>
                </td>
                <td>
                  <?php print $row['description']; ?>
                </td>
                <td>
                  <?php print $row['supplierCode']; ?>
                </td>
                <td>
                  <?php print $row['cost']; ?>
                </td>
                <td>
                  <?php print $row['price']; ?>
                </td>
                <td>
                  <?php print $row['onHand']; ?>
                </td>
                <td>
                  <?php print $row['reorderPoint']; ?>
                </td>
                <td>
                  <?php print $row['backOrder']; ?>
                </td>
                <td>
                  <?php 
if($row['deleted']=="n")
{ 
?>
<a href="view.php?DeleteRestore=<?php echo $row['id'];?>">Delete</a>

   <?php    
    }


    if($row['deleted']=="y")
      {

   ?>
      <a href="view.php?DeleteRestore=<?php echo $row['id'];?>"></a><?php
      }
?>
 </td>
 </tr>

<?php
}
?>
</table>
</br>

</div>
 </body>
  <footer>
     <?php
         printFooter()
     ?>
  </footer>
</html>
4

2 に答える 2

0

なぜあなたはそのためにajaxを使わないのですか?

または、最初に DB の状態を更新してから、すべてのレコードを選択します。その後、ページをリロードする必要はありません。

于 2013-10-15T21:34:35.470 に答える