简体   繁体   English

如何制作一个表格,该表格将更新我的表并在TeamStats页面上连续显示?

[英]How Can I Make a Form That Will Update My Table and Display as a Row on My TeamStats Page?

I was wanting to make a form that will allow me to update my tables in my database and will then display on my pre-made table on my webpage. 我想制作一个表格,使我可以更新数据库中的表,然后将其显示在网页上的预制表中。 I was wanting to at least able to insert data, but being able to also say delete a row with the form would be great too. 我想至少能够插入数据,但是也可以说用表格删除一行也很棒。

I have my tables in phpadmin. 我在phpadmin中有表格。 I wanted this form to be able to update what I have in phpadmin and then display as a new table row in my table on my webpage. 我希望此表单能够更新phpadmin中的内容,然后在网页上的表中显示为新的表行。 Below is an example table I have and I had called some values already from my database. 下面是一个示例表,我已经从数据库中调用了一些值。

<!DOCTYPE html>
<html>
<head>
</head>
<body>      
<center>
<div>
<div class="container">
<table class="responsive-table">
<thead>
  <tr>
    <th scope="col">Team Name</th>
    <th scope="col">Match Result</th>
    <th scope="col">Date Played</th>
    <th scope="col">Location</th>

  </tr>
 </thead>
 <tfoot>
  <tr>
    <td colspan="4">User: <?=$_SESSION['name']?></td>
  </tr>
 </tfoot>
 <tbody>
  <tr>
    <td scope="row"><?=$Team_Name?></td>
    <td><?=$Match_Result?></td>
   <td><?=$Date_Played?></td>
    <td><?=$Location?></td>
  </tr>
 </tbody> 
 </table>
 </div>
<script 
src='http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'> 
</script>
</div>
<footer id="footer"> 
&copy; 2019
</footer>
</body>
</html>

I would like to be able to insert new information into my Game_List table and then add another row on my webpage. 我希望能够在Game_List表中插入新信息,然后在网页上添加另一行。

Use mysqli functions of PHP, store the result and display it in the table via the short php tag using all the variables where you've stored it. 使用PHP的mysqli函数,存储结果,并使用存储它的所有变量通过短php标签将其显示在表中。

EDIT: A very brief example of how I do it is 编辑:我如何做的一个非常简短的例子是

    $servername = "localhost";
    $username = "root";
    $password = "";
    $UCPdatabase = "sarp_game";

    // Create connection
    $conn = new mysqli($servername, $username, $password);

    // Check connection
    if (!$conn) {
        die("Connection failed: " . mysqli_connect_error($conn));
    }
    else
        mysqli_select_db($conn, $UCPdatabase);

$sql = "SELECT `Model`, `ID`, `Name`, `Level`, `Money`, `authyID` FROM `players` WHERE `Name` = '".$_SESSION['username']."' LIMIT 1";
        $result = mysqli_query($conn, $sql);

        if(!$result){
            echo "Error: ", mysqli_error($conn);
            die("|ABORT|");
        }

        if($rows = mysqli_fetch_assoc($result)){
            $skin = "<img src=\"".dirname(dirname(dirname($_SERVER['PHP_SELF'])))."\images\skins\\".$rows['Model'].".png\" height=\"300px\" width=\"400px\">";
            $skin = str_replace('\\', '/', $skin);
            echo $skin."<br>";
            echo "<div id=\"content\">ID: {$rows['ID']} | Name: {$rows['Name']} | Level: {$rows['Level']} | Money: $ {$rows['Money']}</div>";
            echo "<br>";
    ```

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM