0

Hello everyone i have facing problem in creating a array of sub categories.

below is my html code,where user can add category name crossponding this he can add any number of sub category its image and detail by adding on add-more sub category,(form is duplicated by clicking button)

                                        <input type="text" name="addcatagory" placeholder="Category Name" id="addCatagory" class="form-control"/><br/>
                                        <input type="hidden" id="reg_admin_id" name="reg_admin_id" >

                                       <input type="text" name="subcatagory[]" placeholder="Sub Category Name" id="subCatagory" class="form-control"/><br/>
                                        <label style="color:#3a99d9">Upload Sub Catagory Image</label><br>
                                        <input type="file" placeholder = "Upload image"  name="subCatFile1[]" class="form-control" id="subCatFile1"><br>
                                        <textarea placeholder="Sub Category Details" id="subCatDetaisId"  name="subCat_Detais[]" class="form-control"/></textarea><br>

now when i post form fields i have this type of array generated
as you can see two sub categories are added crosponding 2 images and details

var_dump($_POST) is --->

array(5) {
  ["addcatagory"]=>
  string(8) "CATEGORY"
  ["reg_admin_id"]=>
  string(2) "25"
  ["subcatagory"]=>
  array(2) {
    [0]=>
    string(9) "SUB CAT 1"
    [1]=>
    string(9) "sub cat 2"
  }
  ["subCat_Detais"]=>
  array(2) {
    [0]=>
    string(20) "details of sub cat 1"
    [1]=>
    string(20) "details of sub cat 2"
  }
  ["submit"]=>
  string(15) "Submit Catagory"
}

similar $_FILES have values to
now when entering data in to database how can i find that sub cat 1 has image 1.jpg and details is details of sub cat 1 not of other sub category??

more clearly i want to create array like

 ["subcategory"]=>array(2) {
                    sub_cat 1 aray{
                    its details like image and details
                    }
sub_cat 2 array{
                    its details like image and details
                    }

plz help i have sttuck at this.. guide me

2
Contributors
2
Replies
14
Views
1 Year
Discussion Span
Last Post by lps
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.