Php 如何使用<;传递复选框值;a href

Php 如何使用<;传递复选框值;a href,php,jquery,Php,Jquery,example.php~当我选中example.php网页中的复选框时。。然后单击print按钮,该值将传递给example1.php if($items) { foreach($items as $i) { print"<input name='checkbox[]' type='checkbox' id='checkbox[]' value='$i->logi_id'>"; } } echo "<a href='exa

example.php~当我选中example.php网页中的复选框时。。然后单击print按钮,该值将传递给example1.php
if($items) {    
    foreach($items as $i)
    {
        print"<input name='checkbox[]' type='checkbox' id='checkbox[]' value='$i->logi_id'>";
    }
}

echo "<a href='example1.php?checkbox=" . $checkbox . "'><input type='button' name='print' id='delete' value='Print'></a>"
?>
if($items){
foreach(项目为$i)
{
打印“”;
}
}
回声“”
?>

示例2.php

<?php
$keyword = $_REQUEST['keyword'];
$keycateg = $_REQUEST['keycateg'];
$print = $_REQUEST['print'];    
$checkbox = $_REQUEST['checkbox']; 
$count = count($_REQUEST['checkbox']);

if($print){
    for($i=0;$i<$count;$i++){    
        $del_id = $checkbox[$i];
        $sql = "select * FROM sampleDB WHERE logi_id='$del_id'";
        $result = mysql_query($sql);
    }
}
?>
简单的单词---

复选框=

但不要依赖用户输入,…清理数据

如果我正确理解您的问题,您希望使用链接提交表单,首选的方式是将提交按钮样式设置为链接,但您可以使用javascript使用链接提交表单。你可以在这里找到更深入的解释


我猜他的问题是如何计算复选框的当前值,并以a href“GET”编码方式使用它

我建议不要使用href,而是使用另一个带有post方法“get”(为您编码url)的表单。 否则,我相信您的javascript会被卡住。

$checkbox\u string=htmlentities(http\u build\u query(array('checkbox'=>$checkbox));
$checkbox_string = htmlentities(http_build_query(array('checkbox'=>$checkbox)));

echo "<a href='example1.php?$checkbox_string'>...</a>"
回声“”
我想传递example2.php中文本框的值。。我的问题是解决使用,但我需要的是使用href。。可能不是您的问题,但是
id='checkbox[]'
无效。id只能包含字母、数字、连字符、下划线、句点和冒号,并且第一个字符必须是字母。thx barmar爵士,请您提供建议。对不起,我是这里的新手。您需要在
{…}
中包装
$i->logi\u id
,以在字符串中进行适当的替换。还有一件事:在字符串中放置按钮无效,在某些浏览器中不起作用。如果你想让一个按钮像一个链接一样,可以使用
@Barmar lol…还没有注意到这一点…;)thx 4信息:)实际上是Najzero先生。我程序中的主要问题是我想在另一个网页中传递复选框的值。复选框的值是数据库中查询的结果。。
$checkbox_string = htmlentities(http_build_query(array('checkbox'=>$checkbox)));

echo "<a href='example1.php?$checkbox_string'>...</a>"