dongping4901 2014-04-29 15:20
浏览 43

通过$ _GET传递数组

I have a website selling fruit.

I have a category titled 'fruit' and within that category I have 'apples' and 'oranges'.

The customer chooses which category they desire to search in. Example: 'fruit'.

This is then passed to another page which displays what is in the category 'fruit'.

I then have a check box for each item withing the category. Example:

 <input type="checkbox" name="item['.$x_value.'][]" value="'.$item.'">

$x_value contains the category 'fruit' (in a while loop).

$item contains the item 'apple, orange'.

I am wanting to say; if no checkbox is selected for 'item'

if(!isset($item))

Then return to previous page

die(header("location: select_item.php"))

I am passing the $x_value through the URL using

die(header("location: select_category.php?item = $item"))

My problem is, I give the customer the option to choose 2 items 'apples and oranges'. How can I pass my $item array through the URL and received on the previous page 'select_item.php'

Here is my current code:

Page: Select Item.php

$item = $_GET['item'];
foreach($item as $x => $x_value){    

$query = mysql_query("SELECT * FROM category WHERE item='$x_value'");

while($fetch = mysql_fetch_assoc($query)){

$db_item = $fetch['item'];

echo "<p>";
echo '<input type="checkbox" name="item['.$x_value.'][]" value="'.$db_item.'"> '.$db_item.'';
echo "</p>";
}

echo "<br />";

}

Page: Action Page.php

$item = $_POST['item'];

if(!isset($item)){

die(header("location: select_fruit.php?item=$citem"));
}
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
    • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
    • ¥15 CSAPPattacklab
    • ¥15 一直显示正在等待HID—ISP
    • ¥15 Python turtle 画图
    • ¥15 关于大棚监测的pcb板设计
    • ¥15 stm32开发clion时遇到的编译问题
    • ¥15 lna设计 源简并电感型共源放大器
    • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
    • ¥15 Vue3地图和异步函数使用