3

我正在为我的部门设计一个移动帮助台系统。我目前有一个将数据提交到 MySQL 表的 HTML 表单。然后,我将该表格显示在单独的页面上,每行旁边都有复选框。目前,完整按钮被编码为简单地删除任何已检查的记录。但是,按下此按钮似乎什么也没做。我想知道我做错了什么。

这是代码:

<?php
$host="localhost";
$username="root";
$password="";
$db_name="opentix";
$tbl_name="opentix";

//Connect and Select
mysql_connect("$host","$username","$password") or die("Cannot Connect");
mysql_select_db("$db_name")or die("Cannot Select Database");

$sql="SELECT * FROM $tbl_name";
$result=mysql_query($sql);

$count=mysql_num_rows($result);

?>

<table width="400" border="0" cellspacing="0" cellpadding="0">
<tr>
    <td><form name="OpenTickets" method="post" action"">
<table width="400" border="0" cellspacing="3" cellpadding="0" bgcolor="#CCCCCC">
<tr>
<td bgcolor="#FFFFFF"></td>
<td align="center" colspan="15" bgcolor="#FFFFFF"><strong>Open Tickets</strong>
</td>
</tr>
<tr>
    <td align="center" bgcolor="#FFFFFF"><strong></stong></td>
    <td align="center" bgcolor="#FFFFFF"><strong>Ticket Number</stong></td>
    <td align="center" bgcolor="#FFFFFF"><strong>Time Created</stong></td>
    <td align="center" bgcolor="#FFFFFF"><strong>Room</stong></td>
    <td align="center" bgcolor="#FFFFFF"><strong>If Other</stong></td>
    <td align="center" bgcolor="#FFFFFF"><strong>Problem Type</stong></td>
    <td align="center" bgcolor="#FFFFFF"><strong>Machine Name</stong></td>
    <td align="center" bgcolor="#FFFFFF"><strong>Operating System</stong></td>  
    <td align="center" bgcolor="#FFFFFF"><strong>Problem Description</stong></td>
    <td align="center" bgcolor="#FFFFFF"><strong>Troubleshooting</stong></td>
    <td align="center" bgcolor="#FFFFFF"><strong>Request</stong></td>
    <td align="center" bgcolor="#FFFFFF"><strong>Email</stong></td>
</tr>

<?php
while($rows=mysql_fetch_array($result)){
    ?>
<tr>
    <td><input name="checkbox[]" type="checkbox" id="checkbox[]" value="<? echo $rows['tixnum']; ?>".</td>
    <td bgcolor="#FFFFFF"><? echo $rows['tixnum']; ?></td>
    <td bgcolor="#FFFFFF"><? echo $rows['timecreated']; ?></td>
    <td bgcolor="#FFFFFF"><? echo $rows['Room']; ?></td>
    <td bgcolor="#FFFFFF"><? echo $rows['Other']; ?></td>
    <td bgcolor="#FFFFFF"><? echo $rows['Type']; ?></td>
    <td bgcolor="#FFFFFF"><? echo $rows['Name']; ?></td>
    <td bgcolor="#FFFFFF"><? echo $rows['System']; ?></td>
    <td bgcolor="#FFFFFF"><? echo $rows['Problem']; ?></td>
    <td bgcolor="#FFFFFF"><? echo $rows['Troubleshooting']; ?></td>
    <td bgcolor="#FFFFFF"><? echo $rows['Request']; ?></td>
    <td bgcolor="#FFFFFF"><? echo $rows['Email']; ?></td>
</tr>
<?php
}
?>
<tr>
    <td colspan="15" align="center" bgcolor="#FFFFFF"><input name="complete" type ="submit" id="complete" value="Complete"></td>
</tr>
<?php
    if($complete){
        for($i=0;$i<$count;$i++){
            $del_id = $checkbox[$i];
            $sql = "DELETE FROM opentix WHERE id='$del_id'";
            $result = mysql_querry($sql);
        }
if($result){
    echo"<meta http-equiv=\"refresh\"content=\"0;URL=pcsehelpdesk\completeopen.php\">";
}
}
mysql_close();
?>

</table>
</form>
</td>
</tr>
</table>

任何对我做错的事情的投入都会很棒。

4

1 回答 1

0

看起来您需要告诉表单发布给自己。将此添加到您的标签中:

<form action="<?php echo $_SERVER['PHP_SELF']; ?>"

更多阅读:http: //tycoontalk.freelancer.com/php-forum/51903-php-self-submitting-form.html

于 2012-04-11T17:07:16.527 回答