In my project we have to chose categories and it shows the subcategories of corresponding categories. After choosing subcategories it redirecting to that particular page. for redirection, switch case is used. now the problem is now I want to get the subcategories which I chosen in first page is shown in a redirected page. I don't want to put manually for each and every page. because i got more then 35 pages and subcategories. some of the categories and subcategories having same page to redirect, so i want to get the subcategories dynamically.
Here is my coding for index page:
<select name="category" class="form-control" id="category" >
<option value="">select category</option>
<?php
$qCategory = mysql_query("select * from `category` order by id asc");
while($rCategory = mysql_fetch_assoc($qCategory)){
?>
<option value="<?php print $rCategory['id'];?>"><?php print $rCategory['name'];?></option>
<?php
}
?>
</select></div><div class="form-group"><label for="ListingSubcategoryId"> </label>
<select name="sub_category" id="sub_cat" class="form-control" style="display:none;">
</select>
i get my sub categories through javascript. i use this in a form, and a form action is going to next page and that page i got the id of the particular subcategory, put id into switch case and redirect to some page.
<?php
if(isset($_POST['Submit']));
{
$cat= $_POST["category"];
$subcat= $_POST["sub_category"]
switch ($cat) {
case '2':
header('Location: step3.php?cat='.$cat.'sub='.$subcat);
break;
case '3':
header('Location: step3.php?cat='.$cat.'sub='.$subcat);
break;
case '4':
header('Location: step4.php?cat='.$cat.'sub='.$subcat);
break;
}
}
?>
Now I want that page is redirected by which id has to been display on particular page. here in the coding case case 2 and 3 id has same page. but id is different. so that I need dynamically show the subcategory in the page. i also display the "id" in URL. but i dont know how to pick that id into my page. please, any one give some idea.