把复选框放在表格html php中的项目旁边

时间:2017-02-06 20:40:07

标签: php html checkbox

我有一个网页,允许用户查看我的Beaglebone上的SD卡上的日志文件。在此网页上,是一个包含指向日志文件的超链接的表,以便当用户想要查看它们时,他们会单击特定的日志文件并将其下载到本地系统。现在,我想在我的HTML表格中放置这些项目旁边的复选框,以便用户可以在需要时将它们从beaglebone服务器上删除。

在我尝试将表格放入复选框的表单之前,代码工作正常。它出现了这样: this issue

但是在添加表单后,没有任何内容显示出来。 文件<?php $url = $_SERVER['DOCUMENT_ROOT']; $path = "/var/www/html/Logs"; $dh = opendir($path); $k=0; $foo=True; while (($file = readdir($dh)) !== false) { if($file != "." && $file != "..") { #echo "<a href='Logs/$file'>$file</a>"; if($k==0 || $k %7==0){ $col .= "<tr><td><input type="checkbox" name="file[]" value="Logs/$file"><a href='Logs/$file'>$file</a><br /></td>"; } else if($k %7==6){ $col .= "<td><input type="checkbox" name="file[]" value="Logs/$file"><a href='Logs/$file'>$file</a><br /></td></tr>"; } else{ $col .= "<td><input type="checkbox" name="file[]" value="Logs/$file"><a href='Logs/$file'>$file</a><br /></td>"; } $k++; } } echo "<form action="unlink.php" method="get"><table>$col</table><input type="submit" name="formSubmit" value="Submit" /></form> "; closedir($dh); ?> 指的是删除文件的代码。 这是代码:

 protected void btnSpeichern_Click(object sender, EventArgs e)
 {
    string constr = ConfigurationManager.ConnectionStrings["conn"].ConnectionString;
    using (SqlConnection conn = new SqlConnection(constr))
    {
        using (SqlCommand cmd = new SqlCommand())
        {
            cmd.Connection = conn;
            cmd.CommandText = "INSERT INTO tbl_mag(1_1_txt) VALUES(@1_1_txt)";
            {
                cmd.Parameters.AddWithValue("@1_1_txt", txt1.Text.Trim());

                conn.Open();
                cmd.ExecuteNonQuery();
                conn.Close();
            }
        }
    }
}

1 个答案:

答案 0 :(得分:1)

您回显表单标记和表格的行,您需要转义字符串中的所有双引号或将它们全部更改为单引号。您有"<form method="get">..."之类的字符串,并且在双引号内使用双引号会导致错误。它应该更像是:

echo "<form action='unlink.php' method='get'><table>$col</table><input type='submit' name='formSubmit' value='Submit' /></form> ";

如果您查看了php写入的错误日志,您会看到此错误。