如何使用php脚本从html表更改mysql列 [英] How to change mysql column from html table with php scripting

查看:81
本文介绍了如何使用php脚本从html表更改mysql列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好coders< 3我是php,mysql的初学者,现在我被困在一个地方。我有一个表中有批准和拒绝按钮,我希望每当我点击批准按钮时,它会改变它在mysql表中批准的状态。我怎么做....通过按钮点击



这里是我的mysql表图片



http://i.stack.imgur.com/zfjE4.jpg [ ^ ]



这里是UI



http://i.stack.imgur.com /c8Xbn.jpg [ ^ ]



和编码是这样的



Hi coders <3 I am a beginner in php, mysql thing and now i am stuck in one place. I have a table with approve and reject button in it, i want whenever I will will click on approve button, it will change the status of it as approved in the mysql table. How can i do this....through button click

here is my mysql table pic

http://i.stack.imgur.com/zfjE4.jpg[^]

here is the UI

http://i.stack.imgur.com/c8Xbn.jpg[^]

and the coding is like this

<?php

 // Connect to the database

$dbLink = new mysqli('127.0.0.1', 'root', '', 'hct_db');

if(mysqli_connect_errno()) {

    die("MySQL connection failed: ". mysqli_connect_error());

}



 // Query for a list of all existing files

$sql = 'SELECT `quote_id`, `name`, `mime`, `size`, `created`, `status` FROM `quote`';

$result = $dbLink->query($sql);

// Check if it was successfull
if($result) {
   // Make sure there are some files in there
    if($result->num_rows == 0) {
    echo '<p>There are no files in the database</p>';
}
else {?>

                        <div class="table-responsive">
                            <table class="table table-striped table-bordered table-hover" id="dataTables-example">
                                <thead>
                                    <tr>
                                        <th>Quote ID</th>
                                        <th>File Name</th>
                                       <th>File</th>
                                        <th>Size</th>
                                    <th>Created</th>
                                        <th></th>
                                        <th></th>
                                        <th></th>

                                    </tr>

                                </thead><tbody>
                               <?php

    while($row = $result->fetch_assoc()) {
    if ($row["status"]=="Not Approved")
    {
         echo "<tr>";
   echo "<td>" . $row['quote_id'] . "</td>";

  echo "<td>" . $row['name'] . "</td>";

     echo "<td>" . $row['mime'] . "</td>";
  echo "<td>" . $row['size'] . "</td>";
  echo "<td>" . $row['created'] . "</td>";
echo '<td><a href="get_file.php?quote_id=' . $row['quote_id'] .'">Download</a></td>';
echo "<td><input type='submit' name='submit' value='Approved'></td>";
echo "<td><input type='submit' name='submit' value='Reject'></td>";

echo "</tr>";
    }}
    ?>
</tbody>
</table>
</div>
                           </div>
                        <!-- /.table-responsive -->

<?php

$result->free();
}
// Close the mysql connection
$dbLink->close();}
?>

推荐答案

dbLink = new mysqli('127.0.0.1', 'root', '', 'hct_db');

if(mysqli_connect_errno()) {

die(MySQL connection 失败: mysqli_connect_error());

}



// 查询 a list all / span> 现有 文件

dbLink = new mysqli('127.0.0.1', 'root', '', 'hct_db'); if(mysqli_connect_errno()) { die("MySQL connection failed: ". mysqli_connect_error()); } // Query for a list of all existing files


sql =' SELECT` quote_id`,`name`,`mime`,`size`,`created`,`status` FROM`de quote`' ;

< span class =code-summarycomment>
sql = 'SELECT `quote_id`, `name`, `mime`, `size`, `created`, `status` FROM `quote`';


result =
result =


这篇关于如何使用php脚本从html表更改mysql列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆