English 中文(简体)
如何删除关于《京都议定书》缔约方会议的多个项目?
原标题:How to delete multiple item on php session?
  • 时间:2012-05-11 04:03:42
  •  标签:
  • php
  • session

然而,我的问题是,当我删除了它赢得的多个项目时,如果我只删除一个支票箱子上的项目,那么我在这里的工作是我下面的法典,如果我的法典有错的话:

 $cart = $_SESSION[ items ];

if(isset($_POST[ del ])) {

  if ($cart) {
  $newcart = array();
  foreach ($cart as $item) {

    foreach ($_POST[ itemid ] as $del) {
        $delete = $del;
    }

    if ($del != $item) {

          if ($newcart !=   ) {
            $newcart[] = $item;
          } else {
            $newcart[] = $item;
          }

    }   


  }
  $cart = $newcart; 
  }

}

$_SESSION[ items ] = $cart;

这里我采取的形式是:

<form action="cart.php" method="post">
<table>
<tr>
<td><input type="checkbox" name="itemid[]" value="1"></td><td>Item 1</td><td>5</td>
</tr>
<tr>
<td><input type="checkbox" name="itemid[]" value="2"></td><td>Item 2</td><td>5</td>
</tr>
<tr>
<td><input type="checkbox" name="itemid[]" value="3"></td><td>Item 3</td><td>5</td>
</tr>
<tr>
<td><input type="checkbox" name="itemid[]" value="4"></td><td>Item 4</td><td>5</td>
</tr>
<tr>
<td colspan="2"><input type="submit" name="del" value="Delete"></td>
</tr>
</table>
</form>

如果我检查多个项目并提交删除的纽芬兰文,则该项目不删除,但我只检查一个删除的项目。

感谢您的帮助。

最佳回答

你们在守则中都有名称“项目”,但你重新寻找“项目”——这些项目应当彼此相同? 你们喜欢再次与会议价值混淆起来。


接任:

foreach ($_POST[ itemid ] as $del) { 
    $delete = $del; 
} 

仅剩下LAST项目,作为2美元。 你可以尝试

foreach ($cart as $item) { 

    if (!in_array($item, $_POST[ itemid ])) { 

        if ($newcart !=   ) { 
            $newcart[] = $item; 
        } else { 
            $newcart[] = $item; 
        } 

    }    
} 
问题回答

暂无回答




相关问题
why the session in iis automatically log out?

I used iis6, and when i called a function Directory.delete(), the all the session relate this website will be logged out. and i debugged the website, i found no exception. any one have ideas on this ? ...

Check session from a view in CodeIgniter

What is the best way to check session from a view in CodeIgniter, it shows no way in their user guide, otherwise I will have to make two views on everything, which is kinda weird...still a newbie to ...

Can I get the size of a Session object in bytes in c#?

Is it possible to get the size(in bytes) of a Session object after storing something such as a datatable inside it? I want to get the size of a particular Session object, such as Session["table1"], ...

提供严格分类的出席会议物体

提供严格分类的与会机会的最佳方式是什么? 我正计划转而选择矩阵,这正在促使汇编者抱怨我的幻觉方案拟订方法......

PHP Session is not destroying after user logout

I m trying to create an authentication mechanism for my PHP Application and I m having difficulty destroying the session. I ve tried unsetting the authentication token which was previously set within ...

热门标签