lundi 22 juin 2015

Fetch json data in menubar

This is my json data.I am new in json.I am getting this data from web service.I want to fetch this data in menubar.It is three level of categories.Can anyone please help me to display json data in my php file

Json Data :

Array`enter code here`
(
    [0] => Array
        (
            [__type] => GetMobileParentCategoryData:#Flappykart.WCFServices
            [ParentCategoryId] => 151
            [ParentCategoryName] => Electronics
            [ParentCount] => 0
            [objMobileSubCategoryDataList] => Array
                (
                    [0] => Array
                        (
                            [__type] => GetMobileSubCategoryData:#Flappykart.WCFServices
                            [SubCategoryId] => 152
                            [SubCategoryName] => Mobiles
                            [SubCount] => 0
                            [objMobilePetaCategoryDataList] => Array
                                (
                                    [0] => Array
                                        (
                                            [__type] => GetMobilePetaCategoryData:#Flappykart.WCFServices
                                            [PetaCategoryId] => 153
                                            [PetaCategoryName] => Motorola
                                        )

                                )

                        )

                )

        )

    [1] => Array
        (
            [__type] => GetMobileParentCategoryData:#Flappykart.WCFServices
            [ParentCategoryId] => 154
            [ParentCategoryName] => Fashion
            [ParentCount] => 0
            [objMobileSubCategoryDataList] => Array
                (
                    [0] => Array
                        (
                            [__type] => GetMobileSubCategoryData:#Flappykart.WCFServices
                            [SubCategoryId] => 155
                            [SubCategoryName] => Men
                            [SubCount] => 0
                            [objMobilePetaCategoryDataList] => Array
                                (
                                    [0] => Array
                                        (
                                            [__type] => GetMobilePetaCategoryData:#Flappykart.WCFServices
                                            [PetaCategoryId] => 156
                                            [PetaCategoryName] => Shirts
                                        )

                                )

                        )

                    [1] => Array
                        (
                            [__type] => GetMobileSubCategoryData:#Flappykart.WCFServices
                            [SubCategoryId] => 157
                            [SubCategoryName] => Women
                            [SubCount] => 0
                            [objMobilePetaCategoryDataList] => Array
                                (
                                    [0] => Array
                                        (
                                            [__type] => GetMobilePetaCategoryData:#Flappykart.WCFServices
                                            [PetaCategoryId] => 158
                                            [PetaCategoryName] => Dress
                                        )

                                )

                        )

                )

        )

)

Html File call shop_header.php

<?php session_start();
error_reporting(0); 
include 'config.php';
include 'categorylist_services.php';
$categorydata = $_SESSION['category'];
//echo "<pre>"; print_r($categorydata);
?>

<!doctype html>
<!--[if IE 9 ]><html class="ie9" lang="en"><![endif]-->
<!--[if (gt IE 9)|!(IE)]><!--><html lang="en"><!--<![endif]-->
    <head>
        <title>Home | <?php echo TITLE; ?> </title>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
        <!--meta info-->
        <meta name="author" content="">
        <meta name="keywords" content="">
        <meta name="description" content="">
        <link rel="icon" type="image/ico" href="images/fav.ico">
        <!--stylesheet include-->
        <link rel="stylesheet" type="text/css" media="all" href="css/bootstrap.min.css">
        <link rel="stylesheet" type="text/css" media="all" href="css/camera.css">
        <link rel="stylesheet" type="text/css" media="all" href="css/owl.carousel.css">
        <link rel="stylesheet" type="text/css" media="all" href="css/owl.transitions.css">
        <link rel="stylesheet" type="text/css" media="all" href="css/jquery.custom-scrollbar.css">
        <link rel="stylesheet" type="text/css" media="all" href="css/style.css">
        <link rel="stylesheet" type="text/css" media="all" href="css/jquery.fancybox-1.3.4.css">
        <!--font include-->
        <link href="css/font-awesome.min.css" rel="stylesheet">
        <script src="http://ift.tt/1xQsaAf" async defer></script><!--For Recapacha Code-->
    </head>
    <body>
        <!--boxed layout-->
        <div class="boxed_layout relative w_xs_auto">
            <!--[if (lt IE 9) | IE 9]>
                <div style="background:#fff;padding:8px 0 10px;">
                <div class="container" style="width:1170px;"><div class="row wrapper"><div class="clearfix" style="padding:9px 0 0;float:left;width:83%;"><i class="fa fa-exclamation-triangle scheme_color f_left m_right_10" style="font-size:25px;color:#e74c3c;"></i><b style="color:#e74c3c;">Attention! This page may not display correctly.</b> <b>You are using an outdated version of Internet Explorer. For a faster, safer browsing experience.</b></div><div class="t_align_r" style="float:left;width:16%;"><a href="http://ift.tt/JLEkDD" class="button_type_4 r_corners bg_scheme_color color_light d_inline_b t_align_c" target="_blank" style="margin-bottom:2px;">Update Now!</a></div></div></div></div>
            <![endif]-->
            <!--markup header-->
            <header role="banner">
                <!--header top part-->
                <section class="h_top_part">
                    <div class="container">
                        <div class="row clearfix">
                            <div class="col-lg-4 col-md-4 col-sm-5 t_xs_align_c">
                            <?php if( isset( $_SESSION['flappyuser'] ) ) ?>
                            <p class="f_size_small">Welcome <span style="color:#F00;display:run-in;" > <?php if( !isset( $_SESSION['flappyuser'] ) )  { echo "Visior"; echo " ";?><?php } elseif( isset( $_SESSION['flappyuser'] ) )  { ?><?php echo ucwords( $_SESSION['flappyuser'] ); ?><?php } ?></span> you can<?php if( isset( $_SESSION['LoginID'] ) ) { ?>
            <a href="logout.php">Log Out</a>
            <?php } 
            else { ?>
            <a href="login.php">Log In</a>
            <?php } ?>


                                    <?php if( isset( $_SESSION['flappyuser'] ) )  { ?>
                                     </p>
                                    <?php } elseif( !isset( $_SESSION['flappyuser'] ) ) { ?>
                                    <?php echo "or"; ?> <a href="register.php">Create an Account</a> </p>
                                    <?php }?>
                            </div>
                            <div class="col-lg-4 col-md-4 col-sm-2 t_align_c t_xs_align_c">
                                <p class="f_size_small">Call us toll free: <b class="color_dark">(123) 456-7890</b></p>
                            </div>
                            <nav class="col-lg-4 col-md-4 col-sm-5 t_align_r t_xs_align_c">
                                <ul class="d_inline_b horizontal_list clearfix f_size_small users_nav">
                                    <li><a href="myaccount.php" class="default_t_color">My Account</a></li>
                                    <li><a href="trackorder.php" class="default_t_color">Orders List</a></li>
                                    <li><a href="whishlist.php" class="default_t_color">Wishlist</a></li>
                                    <li><a href="checkout.php" class="default_t_color">Checkout</a></li>
                                </ul>
                            </nav>
                        </div>
                    </div>
                </section>
                <!--header bottom part-->
                <section class="h_bot_part container">
                    <div class="clearfix row">
                        <div class="col-lg-6 col-md-6 col-sm-4 t_xs_align_c">
                            <a href="index.php" class="logo m_xs_bottom_15 d_xs_inline_b">
                                <img src="<?php echo LOGO;?>" alt="">
                            </a>
                        </div>
                        <div class="col-lg-6 col-md-6 col-sm-8 t_align_r t_xs_align_c">
                            <ul class="d_inline_b horizontal_list clearfix t_align_l site_settings">
                                <!--shopping cart-->
                                <li class="m_left_5 relative container3d" id="shopping_button">
                                    <a role="button" href="cart.php" class="button_type_3 color_light bg_scheme_color d_block r_corners tr_delay_hover box_s_none">
                                        <span class="d_inline_middle shop_icon m_mxs_right_0">
                                            <i class="fa fa-shopping-cart"></i>
                                            <span class="count tr_delay_hover type_2 circle t_align_c">3</span>
                                        </span>
                                        <b class="d_mxs_none">$355</b>
                                    </a>
                                    <div class="shopping_cart top_arrow tr_all_hover r_corners">
                                        <div class="f_size_medium sc_header">Recently added item(s)</div>
                                        <ul class="products_list">
                                            <li>
                                                <div class="clearfix">
                                                    <!--product image-->
                                                    <img class="f_left m_right_10" src="images/shopping_c_img_1.jpg" alt="">
                                                    <!--product description-->
                                                    <div class="f_left product_description">
                                                        <a href="cart.php" class="color_dark m_bottom_5 d_block">Cursus eleifend elit aenean auctor wisi et urna</a>
                                                        <span class="f_size_medium">Product Code PS34</span>
                                                    </div>
                                                    <!--product price-->
                                                    <div class="f_left f_size_medium">
                                                        <div class="clearfix">
                                                            1 x <b class="color_dark">$99.00</b>
                                                        </div>
                                                        <button class="close_product color_dark tr_hover"><i class="fa fa-times"></i></button>
                                                    </div>
                                                </div>
                                            </li>
                                        </ul>
                                        <!--total price-->
                                        <ul class="total_price bg_light_color_1 t_align_r color_dark">
                                            <li class="m_bottom_10">Tax: <span class="f_size_large sc_price t_align_l d_inline_b m_left_15">$0.00</span></li>
                                            <li class="m_bottom_10">Discount: <span class="f_size_large sc_price t_align_l d_inline_b m_left_15">$37.00</span></li>
                                            <li>Total: <b class="f_size_large bold scheme_color sc_price t_align_l d_inline_b m_left_15">$999.00</b></li>
                                        </ul>
                                        <div class="sc_footer t_align_c">
                                            <a href="cart.php" role="button" class="button_type_4 d_inline_middle bg_light_color_2 r_corners color_dark t_align_c tr_all_hover m_mxs_bottom_5">View Cart</a>
                                            <a href="checkout.php" role="button" class="button_type_4 bg_scheme_color d_inline_middle r_corners tr_all_hover color_light">Checkout</a>
                                        </div>
                                    </div>
                                </li>
                            </ul>
                        </div>
                    </div>
                </section>
          <!--main menu container-->
                <section class="menu_wrap relative">
                    <div class="container clearfix">
                        <!--button for responsive menu-->
                        <button id="menu_button" class="r_corners centered_db d_none tr_all_hover d_xs_block m_bottom_10">
                            <span class="centered_db r_corners"></span>
                            <span class="centered_db r_corners"></span>
                            <span class="centered_db r_corners"></span>
                        </button>
                        <!--main menu-->
                            <?php
        if( isset( $_GET['id'] ) ) {
            $id = $_GET['id'];
        }
        else {
            $storeownerdetail=$_SESSION['storeownerdetail'];
            $id=$storeownerdetail['CategoryId'];
            }
            // echo "<pre>";print_r($categorydata);
        ?> 

                        <nav role="navigation" class="f_left f_xs_none d_xs_none">  
                            <ul class="horizontal_list main_menu clearfix">
                                <li class="current relative f_xs_none m_xs_bottom_5"><a href="index.php" class="tr_delay_hover color_light tt_uppercase"><b>Home</b></a></li>

                                                 <?php foreach($categorydata as $parentcatrgoty)
                                                 {
                                                     $catid = $parentcatrgoty['ParentCategoryId'];
                                                     $catname = $parentcatrgoty['ParentCategoryName'];
                                                //echo "<pre>";print_r($parentcatrgoty['objMobileSubCategoryDataList']);
                                                    ?>   

                                                   <?php ?>
                                <li class="relative f_xs_none m_xs_bottom_5"><a href="index.php?type=1&id=<?php echo $catid; ?>" class="tr_delay_hover color_light tt_uppercase"><b><?php echo $catname; ?></b></a><?php } ?>
                                    <!--sub menu-->
                                    <div class="sub_menu_wrap top_arrow d_xs_none tr_all_hover clearfix r_corners w_xs_auto">
                                        <div class="f_left f_xs_none">


                                          <?php  for ($i = 0; $i < count($categorydata['d']); $i++) 
                                           echo "<pre>";print_r($categorydata['d']);

                                          ?>
                                                    <?php foreach($categorydata as $parentcatrgoty)
                                                 {


                                                     $subcatid = $parentcatrgoty['objMobileSubCategoryDataList'][0]['SubCategoryId'];
                                                     $subcatname = $parentcatrgoty['objMobileSubCategoryDataList'][0]['SubCategoryName'];   ?>
                                            <a href="productdetail.php?type=0&id=<?php echo $subcatid; ?>"><b class="color_dark m_left_20 m_bottom_5 m_top_5 d_inline_b"><?php echo $subcatname; ?></b></a><?php } ?>
                                            <ul class="sub_menu first">
                                                <li><a class="color_dark tr_delay_hover" href="productdetail.php">Evening Dresses</a></li>

                                            </ul>
                                        </div>
                                        <div class="f_left m_left_10 m_xs_left_0 f_xs_none">
                                            <b class="color_dark m_left_20 m_bottom_5 m_top_5 d_inline_b">Accessories</b>
                                            <ul class="sub_menu">
                                                <li><a class="color_dark tr_delay_hover" href="productdetail.php">Bags and Purces</a></li>

                                            </ul>
                                        </div>
                                    </div>
                                </li>


                                <li class="relative f_xs_none m_xs_bottom_5"><a href="contact.php" class="tr_delay_hover color_light tt_uppercase"><b>Contact</b></a></li>
                            </ul>
                        </nav>
                        <button class="f_right search_button tr_all_hover f_xs_none d_xs_none">
                            <i class="fa fa-search"></i>
                        </button>
                    </div>
                    <!--search form-->
                    <div class="searchform_wrap tf_xs_none tr_all_hover">
                        <div class="container vc_child h_inherit relative">
                            <form role="search" class="d_inline_middle full_width">
                                <input type="text" name="search" placeholder="Type text and hit enter" class="f_size_large">
                            </form>
                            <button class="close_search_form tr_all_hover d_xs_none color_dark">
                                <i class="fa fa-times"></i>
                            </button>
                        </div>
                    </div>
                </section>
            </header>




Aucun commentaire:

Enregistrer un commentaire