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"));
}