把复选框放在表格html php中的项旁边 [英] put checkboxes next to items in table html php

查看:113
本文介绍了把复选框放在表格html php中的项旁边的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I have a webpage that allows users to view the log files on the SD card that's on my Beaglebone. On this webpage, is a table with hyperlinks to the log files so that when the user wants to view them, they click on the specific log file and it downloads to their local system. Now, I want to put checkboxes next to these items in my HTML table so that the user can delete them off the beaglebone server when they want to.

代码正在工作在我尝试将表格放入复选框的表单之前完美无缺。它显示如下:

The code was working perfectly before I tried to put the table into a form for the checkboxes. It showed up like this:

但添加表单后,什么也没有显示。
文件 unlink.php 指的是删除文件的代码。
以下是代码:

But after adding the form, nothing shows up. The file unlink.php refers to the code that deletes the files. Here's the code:

<?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);
?> 


推荐答案

,您需要转义字符串中的所有双引号或将其全部更改为单引号。您的字符串像< form method =get> ...,并且在双引号内使用双引号,这会导致错误。它应该更类似于:

The line where you echo out the form tag and table, you need to either escape all the double quotes in your string or change them all to single quotes. You have strings like "<form method="get">..." and are using double quotes within double quotes which will cause an error. It should be something more like:

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

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

If you viewed the error log that php writes to, you would see this error.

这篇关于把复选框放在表格html php中的项旁边的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆