0
我使用PHP來顯示我的MYsql數據庫中的表。我想添加一個刪除按鈕購買,我不知道如何。我想要在最後一列之後的刪除按鈕。這是我的代碼。HTML表格中的MYsql。刪除行
<?php
$db_host = 'localhost';
$db_user = 'root';
$db_pwd = '';
$database = 'coins_gage';
$table = 'coins';
if (!mysql_connect($db_host, $db_user, $db_pwd))
die("Can't connect to database");
if (!mysql_select_db($database))
die("Can't select database");
// sending query
$result = mysql_query("SELECT * FROM {$table}");
if (!$result) {
die("Query to show fields from table failed");
}
$fields_num = mysql_num_fields($result);
echo "<h1>Table: {$table}</h1>";
echo "<table border='1'><tr>";
// printing table headers
for($i=0; $i<$fields_num; $i++)
{
$field = mysql_fetch_field($result);
echo "<td>{$field->name}</td>";
}
echo "</tr>\n";
// printing table rows
while($row = mysql_fetch_row($result))
{
echo "<tr>";
// $row is array... foreach(..) puts every element
// of $row to $cell variable
foreach($row as $cell)
echo "<td>$cell</td>";
echo "</tr>\n";
}
mysql_free_result($result);
?>
我的答案格式不對。有人請編輯它。謝謝。 –
答案是好的,只有通過提交表單中的選項框來簡化它(「選定」值將被刪除) – alfasin