【发布时间】:2014-06-29 04:46:06
【问题描述】:
我已经在这附近呆了好几个小时了,但我不知道该去哪里。
我想从表中的 mysql 更新输出 PHP 查询中的字段。
我只需要一个小按钮或类似的东西就可以在该记录的某个字段中插入“是”。
这是我的代码:
<body>
<?php
$connection = mysql_connect('localhost', 'root', ''); //The Blank string is the password
mysql_select_db('test');
mysql_set_charset('utf8');
$query = "SELECT * FROM simulac";
$result = mysql_query($query);
echo "<table>"; // start a table tag in the HTML
while($row = mysql_fetch_array($result)){ //Creates a loop to loop through results
echo "<tr><td>" . $row['id'] . "</td><td>" . $row['name'] . "</td><td>" . $row['over'] . "</td><td><form action="" method="POST"><input type="submit" value="Concluido" name="submit" class="enviar" /></form></td></tr>"; }
echo "</table>"; //Close the table in HTML
mysql_close(); //Make sure to close out the database connection
?>
</body>
我只是停在这里,因为它开始让我出错,我想知道是否有更好的方法来做到这一点..
【问题讨论】:
-
我不确定你想要什么,但那可能是我。无论如何,我首先建议使用 PDO 连接到您的数据库,或者至少使用 MySQLi,它们都更安全!
-
感谢您的建议,我会调查一下 :)
标签: php mysql html-table row edit