如何在PHP和SQL中显示更新查询的所有结果

时间:2016-07-14 08:55:34

标签: php mysql sql

<?php
include 'core/init.php';
include 'includes/overall/header.php';  

if(isset($_POST['btn_submit'])){

  $sqlQuery = mysql_query("UPDATE `position` SET `ATR`='".mysql_real_escape_string($_POST['ATR'])."'");

  if(mysql_query($connection, $sqlQuery)){
        header('Location:page2.php');
    }
    else{
        echo "Error" .mysql_error();
    }

    $result = "SELECT  * FROM position";
    $finalResult = mysql_query($result) or die(mysql_error());

}
?>

<h2><font color="blue">Table that shows edit history:</h2>
<table border="1" cellpadding="5px" cellspacing="0" width="60%">
     <tr>
     <th><strong>row1</strong></th>
     <th><strong>row2</strong></th>
     <th><strong>row3</strong></th>
     <th><strong>row4</strong></th>
     <th><strong>row5</strong></th>
     </tr>

     <?php 

   while($row5 = mysql_fetch_assoc($finalResult)) { 
         echo "<td>".$row5['row1']."</td>";
         echo "<td>".$row5['row2']."</td>";
         echo "<td>".$row5['row3']."</td>";
         echo "<td>".$row5['row4']."</td>";
         echo "<td>".$row5['row5']."</td>";

     ?>

此代码目前只显示一行更新我正在尝试做的是显示所有更新,当我刷新它消失时,我的目标是创建更新历史记录,抱歉我是新的php谢谢!。

0 个答案:

没有答案