php将选中项插入mysql

php将选中项插入mysql,php,javascript,mysql,Php,Javascript,Mysql,我需要帮助。我只想将已签出的项目提交到mysql表 以下是从php页面呈现的html: <table id="mylist" data-campaignId="2" cellspacing="0" width="100%"> <tbody> <tr> <td><input type="checkbox" name="selected[]" value="92" class="checkbox"></td

我需要帮助。我只想将已签出的项目提交到mysql表

以下是从php页面呈现的html:

<table id="mylist" data-campaignId="2" cellspacing="0" width="100%">
<tbody>
        <tr>
      <td><input type="checkbox" name="selected[]" value="92" class="checkbox"></td>
      <td><a href="/client/view/92">Bob</a></td>
      <td><ul class="keywords">
          <li><a href="#">Peter T</a></li>
          <li class="orange-keyword"><a href="#">New Lead</a></li>
        </ul></td>
      <td>(555) 555-5555</td>
      <td>dad@msn.com.com</td>
      <td>2011-03-21</td>
      <td class="table-actions"><a href="/client/view/92" title="View / Edit" class="with-tip"><img src="/images/icons/fugue/pencil.png" width="16" height="16"></a></td>
    </tr>
    <tr>
      <td><input type="checkbox" name="selected[]" value="1074" class="checkbox"></td>
      <td><a href="/client/view/1074">Elinda Canty</a></td>
      <td><ul class="keywords">
          <li><a href="#">Mary</a></li>
          <li class="orange-keyword"><a href="#">New Lead</a></li>
        </ul></td>
      <td></td>
      <td>mary@live.com</td>
      <td>2011-06-29</td>
      <td class="table-actions"><a href="/client/view/1074" title="View / Edit" class="with-tip"><img src="/images/icons/fugue/pencil.png" width="16" height="16"></a></td>
    </tr>

</tbody>
</table>
<button id="add_users_to_campaign">Add Selected to Subscribers</button>
这是活动模式->将用户添加到活动

function add_user_to_campaign($data)
{
    $this->db->insert('campaign_to_client',$data);

    $newid = $this->db->insert_id();
    return $newid;
}

当我勾选一个项目并提交时,页面会刷新,没有错误,也没有插入任何内容。

不要在第一个实例中全部执行这四项操作(即,让您绕过它),只尝试表中的一行,看看是否有效

你也应该考虑不要使用每个项目的相同名称。i、 e.使用

<input type="checkbox" name="selected[1]" class="checkbox" value="yes">
<input type="checkbox" name="selected[92]" class="checkbox" value="yes">
<input type="checkbox" name="selected[1024]" class="checkbox" value="yes">
米老鼠示例

PHP优先

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
</head>
<body>
<pre>

The forms data
<?php
$selector = $_GET['selector'];
print_r($selector);
echo "Now go through than data\n";

foreach ($selector as $name=>$value)
{
    // Find the name
    $character = $_GET["id$name"];

    echo "$character is $name or $value depends on the method you chose\n";
}
echo "\n\nThose are the checked ones";
?>
</pre>
</body>
</html>

表格数据
以下是表格:


维布勒
检查1
检查80
支票200元
检查1
检查80
支票200元

信息来自哪里-例如
活动ID
客户端ID
创建日期
?信息来自php搜索结果页面。creationdate将只是它插入的当前日期(时间戳)。我尝试了这个方法,但帮助对我来说太复杂了,所以我简化了我的问题。首先添加一个“将值属性添加到”复选框,并显示您迄今为止所做的尝试。@Salman接受了您的建议,但现在是什么?Dev-我添加了clientid的属性值,并在上面进行了编辑。Ed谢谢,但我读到,所选内容必须与实际情况一样,以某种方式检查它是否被选中???-1“进一步编辑”行上方的所有内容。事实上,低于这条线的每件事都是-1。萨尔曼A-为什么不自己回答呢。名称/值对必须是唯一的。顺便说一句-这个问题已经从原来的问题编辑了很多。Ed它必须在我的函数中…我只是没有掌握这个…我的插入是错误的…grrrr…点击这里的头上的墙->砖墙见上面(再次)-这是一个简单的例子,应该给你如何做的指针。(需要添加检查等)。在稍后阶段添加Javascript。
<input type="checkbox" name="selected[1]" class="checkbox" value="yes">
<input type="checkbox" name="selected[92]" class="checkbox" value="yes">
<input type="checkbox" name="selected[1024]" class="checkbox" value="yes">
<input type="checkbox" name="selected[]" class="checkbox" value="1">
<input type="checkbox" name="selected[]" class="checkbox" value="92">
<input type="checkbox" name="selected[]" class="checkbox" value="1024">
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
</head>
<body>
<pre>

The forms data
<?php
$selector = $_GET['selector'];
print_r($selector);
echo "Now go through than data\n";

foreach ($selector as $name=>$value)
{
    // Find the name
    $character = $_GET["id$name"];

    echo "$character is $name or $value depends on the method you chose\n";
}
echo "\n\nThose are the checked ones";
?>
</pre>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>Wibble</title>
</head>
<body>
<form action="send.php" method="get">
<input type="hidden" name="id0" value="client Joe Bloggs">
<input type="hidden" name="id1" value="Client Bugs Bunny">
<input type="hidden" name="id2" value="Client Al Capone ">
Check 1 <input type="checkbox" name="selector[]" value="1">
Check 80 <input type="checkbox" name="selector[]" value="80">
Check 200 <input type="checkbox" name="selector[]" value="200">
<input type="submit" value="depends">
</form>
<form action="send.php" method="get">
<input type="hidden" name="id1" value="client Joe Bloggs">
<input type="hidden" name="id80" value="Client Bugs Bunny">
<input type="hidden" name="id200" value="Client Al Capone ">
Check 1 <input type="checkbox" name="selector[1]" value="yes">
Check 80 <input type="checkbox" name="selector[80]" value="yes">
Check 200 <input type="checkbox" name="selector[200]" value="yes">
<input type="submit" value="otherway">
</form>

</body>
</html>