无法更新使用php返回的第一行

时间:2015-06-29 08:15:47

标签: php mysqli

我创建了一个页面,用于显示表格中的行,并带有一个存档/删除按钮,将删除的标志设置为1,这样可以正常工作。但是,如果我按下第一行的按钮,则无法运行存档/删除php代码。我可以更新其他行,但不会更新第一行。任何想法或帮助都会得到赞赏。

删除行选项的主页

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<?php include 'librarylinks.php'; ?>
</head>
<body >
<?php include 'main_nav_bar.php'; ?>
<div id="container">
<?php
require_once('db_login.php');
$result = $conn->query("SELECT * FROM masstimes where mt_deleted = 0");
if (!$result) {
die($mysqli->error);
}
if ($result->num_rows > 0) { 
// output data of each row
echo ' 
<form id="form1" name="form1" method="POST"">
<table class="table table-condensed table-hover" >
<tr></tr>
';
while($row = $result->fetch_assoc()) {   
$mt_serial = $row["mt_serial"];
$mt_description1 = $row["mt_description1"];
$mt_description2 = $row["mt_description2"];
echo '
<tr>
<td><p>' . $mt_description1 . '</p></td>
<td><p>' . $mt_description2 . '</p>
<a class="btn btn-danger btn-xs just_hide file_actions" data-toggle="modal" data-target="#delete_confirm' . $mt_serial . '"> <i class="glyphicon glyphicon-trash  " style="cursor\:pointer"/></i> Delete </a></td>
</tr>
';
echo '
<div class="modal fade" id="delete_confirm' . $mt_serial . '">
<div class="modal-dialog modal-sm">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
</div>
<div class="modal-body">
<p class="text-center" style="font-size: bold">Are you sure you want to delete this comment?<span id="del_serial"></span>
</p>
</div>
<div class="modal-footer">
<form id="form1" name="form1" method="POST"     action="delete_mass_times.php">                 
<button type="button" class="btn btn-success btn-xs" data-dismiss="modal"><i class="glyphicon glyphicon-remove"></i> Cancel</button>
<input type="hidden" name="mt_serial" value="'. $mt_serial . '">
<input type="submit" name="delete_mts" id="delete_mts" value="Confirm Deletion" />
</form>
</div>
</div>
</div>
</div> ';   
}
echo '</table>
</form>';
}
?>
</div>
</body>
</html>

这是实际删除行

的大PHP
<?php
require_once('db_login.php');
//EXTRACT THE INFORMATION FROM THE WEB FORM
$mt_serial = intval($_POST['mt_serial']);
// Create connection
$conn = new mysqli($servername, $dbusername, $dbpassword, $dbname);
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
} 

$del_result ="UPDATE masstimes SET mt_deleted = 1 where mt_serial =     $mt_serial";
$conn->query($del_result);
echo $del_result;
?>

1 个答案:

答案 0 :(得分:0)

请在开始时删除表单....

var arrayStr = inStr.split(':');
textbox1.text = arrayStr[1];

因为你已经为每一行使用了单独的表格......