开发者

Not echoing checked checkboxes

 echo "<form action='recent.php' method='post' enctype='multipart/form-data'>";
        echo "<table id='logs' border='1' cellspacing='0' width='62%'>";
        echo "<tr>";
        echo "<th width='15%'>Time Logged</th>";
        echo "<th width='15%'>Username</th>";
        echo "<th width='15%'>Password</th>";
        echo "<th width='15%'>IP Address</th>";
        echo "<th width='2%'><a href=\"#\" onclick=\"checkAll(this);\">Mark</a></th>";
        echo "<th width='2%'>Delete</th>";

        echo "</tr>";
        while ($row = mysql_fetch_row($result))
        {
            echo "<tr>";
            echo ("<p><td>$row[2]</td><td>$row[0]</td><td>$row[1]</td><td><i>$row[3]</i></td><td&开发者_如何学运维gt;<center><input type=\"checkbox\" name=\"mark[]\" value=\"$row[0]\" id=\"$row[0]\"></center></td><td><a href=\"delete.php?time=$row[2]&user=$row[0]&pass=$row[1]&ip=$row[3]\"><center>[x]</center></a></td></p>");
            echo "</tr>";
        }
        echo "</table>";
        echo "</form>";

The checkbox <input type=\"checkbox\" name=\"mark[]\" value=\"$row[0]\" id=\"$row[0]\"> Then I have

if ($_GET['mark']) {
            foreach ($_GET['mark'] as $mark) {
                echo "<li>$mark</li>";
            }
        }

But it doesn't show any checked checkboxes. And I also tried putting <input type="submit"> before the closing </form> and it still didn't echo results. What am I doing wrong?


Your form is POSTed but you're looking in $_GET.


A lot of your HTML is just bad markup.

This is wrong <p><td></td></p> It should be <td><p></p></td> And <center></center> tags are deprecated.

<input type="checkbox" value="value" name="name" checked />


Well, unless there's some new php syntax I haven't heard of (which is quite possible), don't you have to jump out of the string to use PHP variables? Like this:

echo "<li>".$mark."</li>";

If that's true, you have the same problem in your top script.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜