html和php更新系统无法正常工作

时间:2017-07-23 15:11:55

标签: php html sql

我正在为我在学校的学生建立一个网站,这将使他们想要学习并获得xp积分,升级......但是当他们升级时,他们会得到一个选择的角色,这在我的数据库中是已知的作为armer_students。我想要的是一个包含sa_id(学生ID)和armer_id的更新系统,系统将更新armer_id。 一切都在我的页面上正确打印,但是当我点击更新按钮上的更新并刷新页面时,没有任何改变......

<?php 

include 'db_functions.php';


$rows = db_select("SELECT * FROM armer_students");
if($rows === false) {
    $error = db_error();
    // Handle error - inform administrator, log to file, show error page, etc.
}





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

         // Quote and escape form submitted values
  $sa_id = $_POST['sa_id'];
  $armer_id = $_POST['armer_id'];

// Insert the values into the database
$sql = "UPDATE students SET armer_id= ".$armer_id ." WHERE sa_id=".$sa_id;
$result = db_query($sql);

    }


?>

<html>
   <head>
     <title></title>
     <link rel="stylesheet" type="text/css" href="style.css" >

   </head>

   <body>
    <?php include 'menu.php'; ?>        
   <table>
            <thead>
                <tr>
                        <th>Id</th>
                        <th>armer id</th>

                </tr>
            </thead>

<?php foreach($rows as $row) :?>
  <tr>
                <td><?php echo $row['sa_id'] ;?></td>
        <td><?php echo $row['armer_id'] ;?></td>



   </tr>
<?php endforeach ;?>


  </table>
   <hr />

               <tr>
                     <td width = "100">sa_id</td>
                     <td><input name = "sa_id" type = "number" id = "sa_id"></td>
                  </tr>
                  <tr>
                     <td width = "100">armer_id</td>
                     <td><input name = "armer_id" type = "number" id = "armer_id"></td>
                  </tr>



                     <tr>
                        <td width = "100"> </td>
                        <td> </td>
                     </tr>

                     <tr>
                        <td width = "100"> </td>
                        <td>
                           <input name = "update" type = "submit" id = "update" value = "Update">
                        </td>
                     </tr>

                  </table>
               </form>
   </body>
</html>     

非常感谢:-)

0 个答案:

没有答案