Solved

MySQL insert Nested Array Objects

Posted on 2013-11-28
16
739 Views
Last Modified: 2013-11-30
I have an associative array, that has been created from JSON data, that has numerous nested arrays.  I want to insert the objects in the nested arrays in an existing MySQL table.  I have the code to do the objects that aren't nested.  So what I need to know is how to reference the nested objects.

Below is an excerpt of the array I am working with.  I need to insert the objects in the nested array named Benifits and HowItWorks in the same field in the DB and in that order.

I would like some html code on the title Benefits and How It Works since these values are being placed in a text field.

array(600) {
  [0]=>
  array(17) {
    ["ID"]=>
    string(36) "199a2f68-66c5-4a4b-9789-3435bbb6fcb3"
    ["PublishDate"]=>
    string(33) "2013-08-05T22:22:01.6041246-04:00"
    ["SKU"]=>
    string(3) "100"
    ["CheckDigit"]=>
    int(1)
    ["Description"]=>
    string(26) "Blessed Thistle (100 caps)"
    ["Benifits"]=>
    array(3) {
      [0]=>
      string(40) "Supports the female reproductive system."
      [1]=>
      string(57) "May help improve digestion as it supports liver function."
      [2]=>
      string(30) "Supports the glandular system."
    }
    ["HowItWorks"]=>
    string(124) "Blessed thistle supports digestion by stimulating secretions of gastric juices and saliva, and stimulating the flow of bile."
    ["Ingredients"]=>
    string(29) "Blessed thistle aerial parts."
    ["RecommendedUse"]=>
    string(40) "Take 2 capsules with a meal twice daily."
    ["Title"]=>
    string(26) "Blessed Thistle (100 caps)"
    ["Status"]=>
    string(5) "Valid"
    ["PriceList"]=>
    array(3) {
      [0]=>
      array(2) {
        ["Type"]=>
        string(2) "QV"
        ["Value"]=>
        string(5) "14.25"
      }
      [1]=>
      array(2) {
        ["Type"]=>
        string(4) "COST"
        ["Value"]=>
        string(5) "14.25"
      }
      [2]=>
      array(2) {
        ["Type"]=>
        string(6) "RETAIL"
        ["Value"]=>
        string(5) "21.40"
      }
    }
    ["ImagePath"]=>
    string(15) "\images\100.jpg"
    ["ImageLable"]=>
    string(15) "\labels\100.jpg"
    ["PDF"]=>
    string(15) "\pdfs\100-1.pdf"
    ["Category"]=>
    NULL
    ["SubCategory"]=>
    NULL
  }
  [1]=>
  array(17) {
    ["ID"]=>
    string(36) "f84f0ff6-1399-42bc-aae9-c323e683d6c7"
    ["PublishDate"]=>
    string(33) "2013-08-05T22:22:05.1297307-04:00"
    ["SKU"]=>
    string(4) "1004"
    ["CheckDigit"]=>
    int(3)
    ["Description"]=>
    string(32) "Lung Support TCM Conc. (30 caps)"
    ["Benifits"]=>
    array(5) {
      [0]=>
      string(46) "May act as a tonic for the respiratory system."
      [1]=>
      string(26) "Maintains tissue surfaces."
      [2]=>
      string(31) "Supports the lungs and sinuses."
      [3]=>
      string(39) "Helps promote mucous membrane moisture."
      [4]=>
      string(66) "Offers additional benefits to the circulatory and urinary systems."
    }
    ["HowItWorks"]=>
    string(672) "

This formula contains the same herbs as Lung Support, but in a highly concentrated blend. This Chinese combination was specially formulated to supplement the needs of a weakened metal constitution. The Chinese call this formula fu lei, which can be translated to mean “strengthen the weak and thin.” Lung Support is considered a lung tonic formula. Its primary herbs—anemarrhena, aster, bupleurum and astragalus—have been used in Traditional Chinese Medicine to boost the immune system, build energy and support the respiratory system.

This formula may be beneficial as a nutritional aid for people experiencing occasional fatigue or loss of weight.
"
    ["Ingredients"]=>
    string(296) "Concentrated extract of astragalus root, aster root, qingjiao root, platycodon root, anemarrhena rhizome, bupleurum root, lycium fruit, ophiopogon root tuber, ginseng root, tang-kuei root, atractylodes rhizome, blue citrus peel, citrus peel, schizandra fruit, typhonium rhizome and licorice root."
    ["RecommendedUse"]=>
    string(142) "Take 1 capsule with a meal daily. NOTE: Pregnant or lactating women should consult their health care provider prior to taking this supplement."
    ["Title"]=>
    string(32) "Lung Support TCM Conc. (30 caps)"
    ["Status"]=>
    string(5) "Valid"
    ["PriceList"]=>
    array(3) {
      [0]=>
      array(2) {
        ["Type"]=>
        string(2) "QV"
        ["Value"]=>
        string(5) "22.15"
      }
      [1]=>
      array(2) {
        ["Type"]=>
        string(4) "COST"
        ["Value"]=>
        string(5) "22.15"
      }
      [2]=>
      array(2) {
        ["Type"]=>
        string(6) "RETAIL"
        ["Value"]=>
        string(5) "33.25"
      }
    }
    ["ImagePath"]=>
    string(16) "\images\1004.jpg"
    ["ImageLable"]=>
    string(16) "\labels\1004.jpg"
    ["PDF"]=>
    string(16) "\pdfs\1004-3.pdf"
    ["Category"]=>
    NULL
    ["SubCategory"]=>
    NULL
  }
  [2]=>
  array(17) {
    ["ID"]=>
    string(36) "d3260833-80e3-4648-8a6f-ab48fce38b35"
    ["PublishDate"]=>
    string(33) "2013-08-05T22:22:07.4853349-04:00"
    ["SKU"]=>
    string(4) "1005"
    ["CheckDigit"]=>
    int(9)
    ["Description"]=>
    string(36) "Blood Stimulator TCM Conc. (30 caps)"
    ["Benifits"]=>
    array(6) {
      [0]=>
      string(68) "Enhances bodily function by improving blood quality and circulation."
      [1]=>
      string(35) "Helps strengthen the immune system."
      [2]=>
      string(31) "Soothes the nerves and muscles."
      [3]=>
      string(44) "Encourages an overall feeling of well-being."
      [4]=>
      string(39) "Helps maintain healthy skin complexion."
      [5]=>
      string(32) "Supports the circulatory system."
    }
    ["HowItWorks"]=>
    string(964) "

This formula contains the same herbs found in Blood Stimulator but in a highly concentrated blend. In addition to the kidneys, the liver is a major facilitator of blood purity. But an effective blood cleanser must deal with all of the cleansing organs, including the colon and skin. This formula is designed to nutritionally support the blood, liver, glands and general circulation.

The Chinese call this formula bu xue, which translates as “to nurture the blood.” It is designed to strengthen a weakened wood constitution.

Blood Stimulator may improve blood quality and purity and help strengthen the immune system. Not only does Blood Stimulator help the body get rid of irritating toxins, it works to prevent more toxic buildup. This herbal combination is “adaptogenic,” meaning it has a tonic effect on the glandular system. This helps normalize hormone production to relieve the stress that comes from hormone imbalance.
"
    ["Ingredients"]=>
    string(373) "Concentrated extract of Ganoderma mushroom, lycium fruit, peony root without bark, tang-kuei root, bupleurum root, cornus fruit without seeds, curcuma root tuber, salvia root and rhizome, achyranthes root, alisma rhizome, astragalus root, atractylodes rhizome, cnidium rhizome, he shou wu root tuber, ligustrum fruit, rehmannia root tuber, cyperus rhizome and ginseng root."
    ["RecommendedUse"]=>
    string(142) "Take 1 capsule with a meal daily. NOTE: Pregnant or lactating women should consult their health care provider prior to taking this supplement."
    ["Title"]=>
    string(36) "Blood Stimulator TCM Conc. (30 caps)"
    ["Status"]=>
    string(5) "Valid"
    ["PriceList"]=>
    array(3) {
      [0]=>
      array(2) {
        ["Type"]=>
        string(2) "QV"
        ["Value"]=>
        string(5) "29.80"
      }
      [1]=>
      array(2) {
        ["Type"]=>
        string(4) "COST"
        ["Value"]=>
        string(5) "29.80"
      }
      [2]=>
      array(2) {
        ["Type"]=>
        string(6) "RETAIL"
        ["Value"]=>
        string(5) "44.70"
      }
    }
    ["ImagePath"]=>
    string(16) "\images\1005.jpg"
    ["ImageLable"]=>
    string(16) "\labels\1005.jpg"
    ["PDF"]=>
    string(16) "\pdfs\1005-9.pdf"
    ["Category"]=>
    NULL
    ["SubCategory"]=>
    NULL
  }
  [3]=>
  array(17) {
    ["ID"]=>
    string(36) "87d03c9a-c8b3-4569-9fef-370b80bd6b11"
    ["PublishDate"]=>
    string(33) "2013-08-05T22:22:11.2137414-04:00"
    ["SKU"]=>
    string(4) "1006"
    ["CheckDigit"]=>
    int(1)
    ["Description"]=>
    string(24) "HY-C TCM Conc. (30 caps)"
    ["Benifits"]=>
    array(3) {
      [0]=>
      string(62) "Helps maintain blood sugar levels already in the normal range."
      [1]=>
      string(47) "Supports the circulatory and glandular systems."
      [2]=>
      string(28) "Supports respiratory health."
    }
    ["HowItWorks"]=>
    string(894) "

This formula contains the same herbs found in Chinese HY-C but in a highly concentrated blend. These herbs nutritionally support the glandular system and associated metabolic processes. According to Traditional Chinese Medicine, this formula is called bu yin, which means to “supplement yin.” In this case, yin is considered moisture. These herbs work to support the body as it attempts to reduce fire and strengthen water (support associated organs and maintain normal metabolic processes).

Rehmannia root helps maintain blood sugar levels already in the normal range. Eucommia has been used to support the liver, kidneys and muscles and to strengthen the lungs. Eucommia is also believed to support cardiovascular function. Ophiopogon is used in Chinese herbology to support yin and lung function. The plant is said to be a moisturizer, moistening the lungs and intestines.
"
    ["Ingredients"]=>
    string(335) "Concentrated extract of eucommia bark, glehnia root, rehmannia root tuber, ophiopogon root tuber, pueraria root, trichosanthes root, achyranthes root, alisma rhizome, anemarrhena rhizome, asparagus root tuber, hoelen sclerotium, moutan root bark, cornus fruit without seeds, licorice root, phellodendron stem bark and schizandra fruit."
    ["RecommendedUse"]=>
    string(142) "Take 1 capsule with a meal daily. NOTE: Pregnant or lactating women should consult their health care provider prior to taking this supplement."
    ["Title"]=>
    string(24) "HY-C TCM Conc. (30 caps)"
    ["Status"]=>
    string(5) "Valid"
    ["PriceList"]=>
    array(3) {
      [0]=>
      array(2) {
        ["Type"]=>
        string(2) "QV"
        ["Value"]=>
        string(5) "22.85"
      }
      [1]=>
      array(2) {
        ["Type"]=>
        string(4) "COST"
        ["Value"]=>
        string(5) "22.85"
      }
      [2]=>
      array(2) {
        ["Type"]=>
        string(6) "RETAIL"
        ["Value"]=>
        string(5) "34.30"
      }
    }
    ["ImagePath"]=>
    string(16) "\images\1006.jpg"
    ["ImageLable"]=>
    string(16) "\labels\1006.jpg"
    ["PDF"]=>
    string(16) "\pdfs\1006-1.pdf"
    ["Category"]=>
    NULL
    ["SubCategory"]=>
    NULL
  }
  [4]=>
  array(17) {
    ["ID"]=>
    string(36) "4dc18837-fcc6-48c8-bd17-246c2a75d029"
    ["PublishDate"]=>
    string(33) "2013-08-05T22:22:13.7565459-04:00"
    ["SKU"]=>
    string(4) "1007"
    ["CheckDigit"]=>
    int(2)
    ["Description"]=>
    string(24) "IF-C TCM Conc. (30 caps)"
    ["Benifits"]=>
    array(4) {
      [0]=>
      string(44) "Nourishes the structural and immune systems."
      [1]=>
      string(68) "Promotes normal blood flow and thus supports the circulatory system."
      [2]=>
      string(57) "Helps in the normal elimination of toxic metabolic waste."
      [3]=>
      string(100) "May help support the body’s natural process for muscle pain relief following exercise and massage."
    }
    ["HowItWorks"]=>
    string(295) "This formula contains the same herbs found in IF-C but in a highly concentrated blend. These herbs nourish the structural and immune systems by stimulating blood flow and supporting the natural elimination of toxic waste through a variety of actions. It may also promote a feeling of well-being."
    ["Ingredients"]=>
    string(341) "Concentrated extract of lonicera flower bud, forsythia fruit, cnidium rhizome, chrysanthemum flowers, gardenia fruit peony root without bark, platycodon root, schizonepeta flower, scute root, arctium fruit, bupleurum root, phellodendron stem bark, siler root, tang-kuei root, vitex fruit, carthamus flowers, coptis rhizome and licorice root."
    ["RecommendedUse"]=>
    string(142) "Take 1 capsule with a meal daily. NOTE: Pregnant or lactating women should consult their health care provider prior to taking this supplement."
    ["Title"]=>
    string(24) "IF-C TCM Conc. (30 caps)"
    ["Status"]=>
    string(5) "Valid"
    ["PriceList"]=>
    array(3) {
      [0]=>
      array(2) {
        ["Type"]=>
        string(2) "QV"
        ["Value"]=>
        string(5) "22.75"
      }
      [1]=>
      array(2) {
        ["Type"]=>
        string(4) "COST"
        ["Value"]=>
        string(5) "22.75"
      }
      [2]=>
      array(2) {
        ["Type"]=>
        string(6) "RETAIL"
        ["Value"]=>
        string(5) "34.15"
      }
    }
    ["ImagePath"]=>
    string(16) "\images\1007.jpg"
    ["ImageLable"]=>
    string(16) "\labels\1007.jpg"
    ["PDF"]=>
    string(16) "\pdfs\1007-2.pdf"
    ["Category"]=>
    NULL
    ["SubCategory"]=>
    NULL
  }
  [5]=>
  array(17) {
    ["ID"]=>
    string(36) "fd6f1292-a983-494f-8fa4-162806494249"
    ["PublishDate"]=>
    string(33) "2013-08-05T22:22:16.0029498-04:00"
    ["SKU"]=>
    string(4) "1008"
    ["CheckDigit"]=>
    int(8)
    ["Description"]=>
    string(33) "Liver Balance TCM Conc. (30 caps)"
    ["Benifits"]=>
    array(5) {
      [0]=>
      string(52) "Supports the hepatic, digestive and nervous systems."
      [1]=>
      string(38) "Supports the liver cleansing function."
      [2]=>
      string(41) "May help reduce stress and restore vigor."
      [3]=>
      string(19) "Enhances digestion."
      [4]=>
      string(36) "May increase feelings of well-being."
    }
    ["HowItWorks"]=>
    string(956) "

This formula contains the same herbs as Liver Balance, but in a highly concentrated blend. Liver Balance is designed to support the needs of a stressed wood constitution. The Chinese call this formula tiao he, which can be translated to mean “harmonizing.” In Traditional Chinese Medicine, it is used to support both the digestive and nervous systems, optimizing liver health and reducing stress.

Its primary herbs—scute, peony, bupleurum and atractylodes—have been used traditionally to maintain normal nervous system function during mental stress and to support the upper digestive system during tension and distress. Bupleurum is the most important “cooling herb” according to Chinese herbology. It is believed to aid the upward flow of chi, or the body’s living force, thereby strengthening the body against stress. Other herbs support these functions in what the Chinese refer to as a “wood-reducing” formula.
"
    ["Ingredients"]=>
    string(238) "Concentrated extract of bupleurum root, peony root without bark, typhonium rhizome, cinnamon twig, dang gui root, fushen sclerotium with root, scute root, zhishi fruit, atractylodes rhizome, ginseng root, ginger rhizome and licorice root."
    ["RecommendedUse"]=>
    string(33) "Take 1 capsule with a meal daily."
    ["Title"]=>
    string(33) "Liver Balance TCM Conc. (30 caps)"
    ["Status"]=>
    string(5) "Valid"
    ["PriceList"]=>
    array(3) {
      [0]=>
      array(2) {
        ["Type"]=>
        string(2) "QV"
        ["Value"]=>
        string(5) "19.00"
      }
      [1]=>
      array(2) {
        ["Type"]=>
        string(4) "COST"
        ["Value"]=>
        string(5) "19.00"
      }
      [2]=>
      array(2) {
        ["Type"]=>
        string(6) "RETAIL"
        ["Value"]=>
        string(5) "28.50"
      }
    }
    ["ImagePath"]=>
    string(16) "\images\1008.jpg"
    ["ImageLable"]=>
    string(16) "\labels\1008.jpg"
    ["PDF"]=>
    string(16) "\pdfs\1008-8.pdf"
    ["Category"]=>
    NULL
    ["SubCategory"]=>
    NULL
  }

Open in new window


Here is my code.  I can get the object Description but not Benifits or HowItWorks.

<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
$jsonData = file_get_contents("http://www.abc.com/data.json");
$phpArray = json_decode($jsonData, true);

foreach ($phpArray as $key => $value) {
    echo "<h2>$key</h2>";
    foreach ($value as $k => $v) {
        echo "$k | $v <br />";
    }
}

// @todo prepare your data, whether you harvest from text files or however.
// @todo Then set your data to the $data variable here.
 
$phpArray = array_filter($phpArray);
 
// @todo edit below with your own database details
$con = mysqli_connect("xx","xxxxx","xxxxx","xxxx");
 
// Check connection
if (mysqli_connect_errno()) {
    echo 'Failed to connect to MySQL: ' . mysqli_connect_error();
    exit();
}
 
unset($success, $fail);
 
foreach ($phpArray as $row) {
    $sqlStr = sprintf("INSERT INTO ps_product_lang_test (name, description) VALUES ('%s', '%s')", $row['Description'], $row['Benifits'][1]['Value'], $row['HowItWorks'][1]['Value']);	
	
//check the SQL statement to make sure it's correct:
var_dump($sqlStr); 
$result = mysqli_query($con, $sqlStr);
       
	  
     
   
}
 
//print $success;
//print $fail;
 
echo '<p>End of script.</p>';
 
mysqli_close($con);
?>

Open in new window


Thanks,

Randal
0
Comment
Question by:sharingsunshine
  • 7
  • 6
  • 2
  • +1
16 Comments
 
LVL 15

Expert Comment

by:Insoftservice
ID: 39684087
Paste the o/p

unset($success, $fail);

echo "<pre>";print_r($phpArray);

foreach ($phpArray as $row) {
0
 
LVL 42

Expert Comment

by:Chris Stanyon
ID: 39684144
Right.

'HowItWorks' is simply a key of the array, so you can get that by calling the key:

echo $row['HowItWorks'];

Open in new window

The benefits though is an array, so you need to decide how you want to insert this into your database. For example the Benefits key contains 3, 4 or 5 values - do you just want to insert 1 value into 1 record, all the values into 1 record, or each value into it's own record:

foreach ($row['Benifits'] as $benefit):
     printf('<p>%s</p>', $benefit);
endforeach;

Open in new window

0
 

Author Comment

by:sharingsunshine
ID: 39684222
With the Benifits key I need to insert all the values into 1 record.  Their variable number of values is what has me stumped.

Also, I am not clear how to nest the foreach for benefits with the other foreach loop.

the O/P is located at http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/Q_28304890.html

Didn't mean to leave in that extra code

unset($success, $fail);


here is the print_r

Array
(
    [0] => Array
        (
            [ID] => 199a2f68-66c5-4a4b-9789-3435bbb6fcb3
            [PublishDate] => 2013-08-05T22:22:01.6041246-04:00
            [SKU] => 100
            [CheckDigit] => 1
            [Description] => Blessed Thistle (100 caps)
            [Benifits] => Array
                (
                    [0] => Supports the female reproductive system.
                    [1] => May help improve digestion as it supports liver function.
                    [2] => Supports the glandular system.
                )

            [HowItWorks] => Blessed thistle supports digestion by stimulating secretions of gastric juices and saliva, and stimulating the flow of bile.
            [Ingredients] => Blessed thistle aerial parts.
            [RecommendedUse] => Take 2 capsules with a meal twice daily.
            [Title] => Blessed Thistle (100 caps)
            [Status] => Valid
            [PriceList] => Array
                (
                    [0] => Array
                        (
                            [Type] => QV
                            [Value] => 14.25
                        )

                    [1] => Array
                        (
                            [Type] => COST
                            [Value] => 14.25
                        )

                    [2] => Array
                        (
                            [Type] => RETAIL
                            [Value] => 21.40
                        )

                )

            [ImagePath] => \images\100.jpg
            [ImageLable] => \labels\100.jpg
            [PDF] => \pdfs\100-1.pdf
            [Category] => 
            [SubCategory] => 
        )

    [1] => Array
        (
            [ID] => f84f0ff6-1399-42bc-aae9-c323e683d6c7
            [PublishDate] => 2013-08-05T22:22:05.1297307-04:00
            [SKU] => 1004
            [CheckDigit] => 3
            [Description] => Lung Support TCM Conc. (30 caps)
            [Benifits] => Array
                (
                    [0] => May act as a tonic for the respiratory system.
                    [1] => Maintains tissue surfaces.
                    [2] => Supports the lungs and sinuses.
                    [3] => Helps promote mucous membrane moisture.
                    [4] => Offers additional benefits to the circulatory and urinary systems.
                )

            [HowItWorks] => 

This formula contains the same herbs as Lung Support, but in a highly concentrated blend. This Chinese combination was specially formulated to supplement the needs of a weakened metal constitution. The Chinese call this formula fu lei, which can be translated to mean “strengthen the weak and thin.” Lung Support is considered a lung tonic formula. Its primary herbs—anemarrhena, aster, bupleurum and astragalus—have been used in Traditional Chinese Medicine to boost the immune system, build energy and support the respiratory system.

This formula may be beneficial as a nutritional aid for people experiencing occasional fatigue or loss of weight.

            [Ingredients] => Concentrated extract of astragalus root, aster root, qingjiao root, platycodon root, anemarrhena rhizome, bupleurum root, lycium fruit, ophiopogon root tuber, ginseng root, tang-kuei root, atractylodes rhizome, blue citrus peel, citrus peel, schizandra fruit, typhonium rhizome and licorice root.
            [RecommendedUse] => Take 1 capsule with a meal daily. NOTE: Pregnant or lactating women should consult their health care provider prior to taking this supplement.
            [Title] => Lung Support TCM Conc. (30 caps)
            [Status] => Valid
            [PriceList] => Array
                (
                    [0] => Array
                        (
                            [Type] => QV
                            [Value] => 22.15
                        )

                    [1] => Array
                        (
                            [Type] => COST
                            [Value] => 22.15
                        )

                    [2] => Array
                        (
                            [Type] => RETAIL
                            [Value] => 33.25
                        )

                )

            [ImagePath] => \images\1004.jpg
            [ImageLable] => \labels\1004.jpg
            [PDF] => \pdfs\1004-3.pdf
            [Category] => 
            [SubCategory] => 
        )

    [2] => Array
        (
            [ID] => d3260833-80e3-4648-8a6f-ab48fce38b35
            [PublishDate] => 2013-08-05T22:22:07.4853349-04:00
            [SKU] => 1005
            [CheckDigit] => 9
            [Description] => Blood Stimulator TCM Conc. (30 caps)
            [Benifits] => Array
                (
                    [0] => Enhances bodily function by improving blood quality and circulation.
                    [1] => Helps strengthen the immune system.
                    [2] => Soothes the nerves and muscles.
                    [3] => Encourages an overall feeling of well-being.
                    [4] => Helps maintain healthy skin complexion.
                    [5] => Supports the circulatory system.
                )

            [HowItWorks] => 

This formula contains the same herbs found in Blood Stimulator but in a highly concentrated blend. In addition to the kidneys, the liver is a major facilitator of blood purity. But an effective blood cleanser must deal with all of the cleansing organs, including the colon and skin. This formula is designed to nutritionally support the blood, liver, glands and general circulation.

The Chinese call this formula bu xue, which translates as “to nurture the blood.” It is designed to strengthen a weakened wood constitution.

Blood Stimulator may improve blood quality and purity and help strengthen the immune system. Not only does Blood Stimulator help the body get rid of irritating toxins, it works to prevent more toxic buildup. This herbal combination is “adaptogenic,” meaning it has a tonic effect on the glandular system. This helps normalize hormone production to relieve the stress that comes from hormone imbalance.

            [Ingredients] => Concentrated extract of Ganoderma mushroom, lycium fruit, peony root without bark, tang-kuei root, bupleurum root, cornus fruit without seeds, curcuma root tuber, salvia root and rhizome, achyranthes root, alisma rhizome, astragalus root, atractylodes rhizome, cnidium rhizome, he shou wu root tuber, ligustrum fruit, rehmannia root tuber, cyperus rhizome and ginseng root.
            [RecommendedUse] => Take 1 capsule with a meal daily. NOTE: Pregnant or lactating women should consult their health care provider prior to taking this supplement.
            [Title] => Blood Stimulator TCM Conc. (30 caps)
            [Status] => Valid
            [PriceList] => Array
                (
                    [0] => Array
                        (
                            [Type] => QV
                            [Value] => 29.80
                        )

                    [1] => Array
                        (
                            [Type] => COST
                            [Value] => 29.80
                        )

                    [2] => Array
                        (
                            [Type] => RETAIL
                            [Value] => 44.70
                        )

                )

            [ImagePath] => \images\1005.jpg
            [ImageLable] => \labels\1005.jpg
            [PDF] => \pdfs\1005-9.pdf
            [Category] => 
            [SubCategory] => 
        )

    [3] => Array
        (
            [ID] => 87d03c9a-c8b3-4569-9fef-370b80bd6b11
            [PublishDate] => 2013-08-05T22:22:11.2137414-04:00
            [SKU] => 1006
            [CheckDigit] => 1
            [Description] => HY-C TCM Conc. (30 caps)
            [Benifits] => Array
                (
                    [0] => Helps maintain blood sugar levels already in the normal range.
                    [1] => Supports the circulatory and glandular systems.
                    [2] => Supports respiratory health.
                )

            [HowItWorks] => 

This formula contains the same herbs found in Chinese HY-C but in a highly concentrated blend. These herbs nutritionally support the glandular system and associated metabolic processes. According to Traditional Chinese Medicine, this formula is called bu yin, which means to “supplement yin.” In this case, yin is considered moisture. These herbs work to support the body as it attempts to reduce fire and strengthen water (support associated organs and maintain normal metabolic processes).

Rehmannia root helps maintain blood sugar levels already in the normal range. Eucommia has been used to support the liver, kidneys and muscles and to strengthen the lungs. Eucommia is also believed to support cardiovascular function. Ophiopogon is used in Chinese herbology to support yin and lung function. The plant is said to be a moisturizer, moistening the lungs and intestines.

            [Ingredients] => Concentrated extract of eucommia bark, glehnia root, rehmannia root tuber, ophiopogon root tuber, pueraria root, trichosanthes root, achyranthes root, alisma rhizome, anemarrhena rhizome, asparagus root tuber, hoelen sclerotium, moutan root bark, cornus fruit without seeds, licorice root, phellodendron stem bark and schizandra fruit.
            [RecommendedUse] => Take 1 capsule with a meal daily. NOTE: Pregnant or lactating women should consult their health care provider prior to taking this supplement.
            [Title] => HY-C TCM Conc. (30 caps)
            [Status] => Valid
            [PriceList] => Array
                (
                    [0] => Array
                        (
                            [Type] => QV
                            [Value] => 22.85
                        )

                    [1] => Array
                        (
                            [Type] => COST
                            [Value] => 22.85
                        )

                    [2] => Array
                        (
                            [Type] => RETAIL
                            [Value] => 34.30
                        )

                )

            [ImagePath] => \images\1006.jpg
            [ImageLable] => \labels\1006.jpg
            [PDF] => \pdfs\1006-1.pdf
            [Category] => 
            [SubCategory] => 
        )

    [4] => Array
        (
            [ID] => 4dc18837-fcc6-48c8-bd17-246c2a75d029
            [PublishDate] => 2013-08-05T22:22:13.7565459-04:00
            [SKU] => 1007
            [CheckDigit] => 2
            [Description] => IF-C TCM Conc. (30 caps)
            [Benifits] => Array
                (
                    [0] => Nourishes the structural and immune systems.
                    [1] => Promotes normal blood flow and thus supports the circulatory system.
                    [2] => Helps in the normal elimination of toxic metabolic waste.
                    [3] => May help support the body’s natural process for muscle pain relief following exercise and massage.
                )

            [HowItWorks] => This formula contains the same herbs found in IF-C but in a highly concentrated blend. These herbs nourish the structural and immune systems by stimulating blood flow and supporting the natural elimination of toxic waste through a variety of actions. It may also promote a feeling of well-being.
            [Ingredients] => Concentrated extract of lonicera flower bud, forsythia fruit, cnidium rhizome, chrysanthemum flowers, gardenia fruit peony root without bark, platycodon root, schizonepeta flower, scute root, arctium fruit, bupleurum root, phellodendron stem bark, siler root, tang-kuei root, vitex fruit, carthamus flowers, coptis rhizome and licorice root.
            [RecommendedUse] => Take 1 capsule with a meal daily. NOTE: Pregnant or lactating women should consult their health care provider prior to taking this supplement.
            [Title] => IF-C TCM Conc. (30 caps)
            [Status] => Valid
            [PriceList] => Array
                (
                    [0] => Array
                        (
                            [Type] => QV
                            [Value] => 22.75
                        )

                    [1] => Array
                        (
                            [Type] => COST
                            [Value] => 22.75
                        )

                    [2] => Array
                        (
                            [Type] => RETAIL
                            [Value] => 34.15
                        )

                )

            [ImagePath] => \images\1007.jpg
            [ImageLable] => \labels\1007.jpg
            [PDF] => \pdfs\1007-2.pdf
            [Category] => 
            [SubCategory] => 
        )

    [5] => Array
        (
            [ID] => fd6f1292-a983-494f-8fa4-162806494249
            [PublishDate] => 2013-08-05T22:22:16.0029498-04:00
            [SKU] => 1008
            [CheckDigit] => 8
            [Description] => Liver Balance TCM Conc. (30 caps)
            [Benifits] => Array
                (
                    [0] => Supports the hepatic, digestive and nervous systems.
                    [1] => Supports the liver cleansing function.
                    [2] => May help reduce stress and restore vigor.
                    [3] => Enhances digestion.
                    [4] => May increase feelings of well-being.
                )

            [HowItWorks] => 

This formula contains the same herbs as Liver Balance, but in a highly concentrated blend. Liver Balance is designed to support the needs of a stressed wood constitution. The Chinese call this formula tiao he, which can be translated to mean “harmonizing.” In Traditional Chinese Medicine, it is used to support both the digestive and nervous systems, optimizing liver health and reducing stress.

Its primary herbs—scute, peony, bupleurum and atractylodes—have been used traditionally to maintain normal nervous system function during mental stress and to support the upper digestive system during tension and distress. Bupleurum is the most important “cooling herb” according to Chinese herbology. It is believed to aid the upward flow of chi, or the body’s living force, thereby strengthening the body against stress. Other herbs support these functions in what the Chinese refer to as a “wood-reducing” formula.

            [Ingredients] => Concentrated extract of bupleurum root, peony root without bark, typhonium rhizome, cinnamon twig, dang gui root, fushen sclerotium with root, scute root, zhishi fruit, atractylodes rhizome, ginseng root, ginger rhizome and licorice root.
            [RecommendedUse] => Take 1 capsule with a meal daily.
            [Title] => Liver Balance TCM Conc. (30 caps)
            [Status] => Valid
            [PriceList] => Array
                (
                    [0] => Array
                        (
                            [Type] => QV
                            [Value] => 19.00
                        )

                    [1] => Array
                        (
                            [Type] => COST
                            [Value] => 19.00
                        )

                    [2] => Array
                        (
                            [Type] => RETAIL
                            [Value] => 28.50
                        )

                )

            [ImagePath] => \images\1008.jpg
            [ImageLable] => \labels\1008.jpg
            [PDF] => \pdfs\1008-8.pdf
            [Category] => 
            [SubCategory] => 
        )

    [6] => Array
        (
            [ID] => 203a3cb3-6e32-4fc3-a95f-710db6e35bc4
            [PublishDate] => 2013-08-05T22:22:18.0153534-04:00
            [SKU] => 1010
            [CheckDigit] => 3
            [Description] => Liver Cleanse Formula (100 caps)
            [Benifits] => Array
                (
                    [0] => Provides nutritional support to the liver and gallbladder.
                    [1] => Promotes cleansing and detoxification mediated by the liver.
                    [2] => Supports digestive functions.
                    [3] => Supports the hepatic system.
                )

            [HowItWorks] => 

The liver performs many important functions in the body. It supports digestive functions by secreting bile for emulsification of fat, controlling the metabolism of nutrients (including alcohols) and serving as a reservoir for many nutrients and metabolites. The liver’s involvement in metabolic functions makes it susceptible to stressors.

Liver Cleanse Formula provides nutritional support to the liver and gallbladder, promotes cleansing and detoxification, and supports digestive function.

Red beet root has traditionally been used to support the liver. Dandelion is reported to have tonic effects on the liver and gallbladder. Parsley contains chlorophyll and thus acts as a natural digestive deodorizer. Horsetail is reported to benefit the gallbladder. Yellow dock is a cleansing and detoxifying herb. Black cohosh exerts antioxidant effects. Birch leaves contain flavonoids, which exert antioxidant effects, thereby supporting the liver. Blessed thistle supports the stomach, intestines and gallbladder. Angelica root has been effectively used for digestive support. It is thought to protect liver cells from oxidative damage. Chamomile exerts demulcent and soothing effects on the gastrointestinal tract. Gentian exerts antioxidant effects. Goldenrod has traditionally been used for liver support.

            [Ingredients] => Red beet root, dandelion root, parsley leaves, horsetail stem and strobilus, yellow dock root, black cohosh root, birch leaves, blessed thistle aerial parts, angelica root, chamomile flowers, gentian root and goldenrod aerial parts.
            [RecommendedUse] => Take 1 capsule with a meal three times daily.
            [Title] => Liver Cleanse Formula (100 caps)
            [Status] => Valid
            [PriceList] => Array
                (
                    [0] => Array
                        (
                            [Type] => QV
                            [Value] => 13.20
                        )

                    [1] => Array
                        (
                            [Type] => COST
                            [Value] => 13.20
                        )

                    [2] => Array
                        (
                            [Type] => RETAIL
                            [Value] => 19.80
                        )

                )

            [ImagePath] => \images\1010.jpg
            [ImageLable] => \labels\1010.jpg
            [PDF] => \pdfs\1010-3.pdf
            [Category] => 
            [SubCategory] => 
        )

    [7] => Array
        (
            [ID] => 602c9b1c-3590-4821-b8eb-7f40103fa889
            [PublishDate] => 2013-08-05T22:22:21.5253595-04:00
            [SKU] => 1011
            [CheckDigit] => 4
            [Description] => LIV-J (100 caps)
            [Benifits] => Array
                (
                    [0] => Supports the digestive and hepatic systems.
                    [1] => Nourishes the liver.
                )

            [HowItWorks] => 

This herbal blend has been used traditionally to support digestion, cleanse the digestive system, and nourish the liver and spleen. Dandelion is reported to have tonic effects on the liver and gallbladder. Parsley contains chlorophyll and acts as a natural digestive deodorizer. Red beet root has traditionally been used to support the liver.

            [Ingredients] => Dandelion root, rose hips, barberry root bark, fennel seeds, parsley leaves, red beet root and horseradish root.
            [RecommendedUse] => Take 2 capsules with a meal three times daily and before bedtime.
            [Title] => LIV-J (100 caps)
            [Status] => Valid
            [PriceList] => Array
                (
                    [0] => Array
                        (
                            [Type] => QV
                            [Value] => 14.25
                        )

                    [1] => Array
                        (
                            [Type] => COST
                            [Value] => 14.25
                        )

                    [2] => Array
                        (
                            [Type] => RETAIL
                            [Value] => 21.40
                        )

                )

            [ImagePath] => \images\1011.jpg
            [ImageLable] => \labels\1011.jpg
            [PDF] => \pdfs\1011-4.pdf
            [Category] => 
            [SubCategory] => 
        )

    [8] => Array
        (
            [ID] => ad0c55af-6f8d-46ab-ac14-88bf83a89379
            [PublishDate] => 2013-08-05T22:22:23.3037627-04:00
            [SKU] => 1016
            [CheckDigit] => 0
            [Description] => KB-C TCM Conc. (30 caps)
            [Benifits] => Array
                (
                    [0] => Strengthens the urinary system.
                    [1] => Supports the structural system, specifically the bones.
                    [2] => May help the body restore energy.
                )

            [HowItWorks] => 

This formula contains the same herbs found in KB-C but in a highly concentrated blend. Its Chinese name jian gu can be translated to mean “strengthen the bones.” It is designed to strengthen the water element. In Traditional Chinese Medicine, this formula is used to nourish the kidneys and nutritionally support the urinary and structural systems, eliminating water and providing extra joint support.

Chinese herbalists believe eucommia nourishes the kidney yang and the ligaments and bones. Eucommia has been used for centuries in the Far East for weakness. No single Western herb has been found to substitute for these qualities. Chinese herbalists also believe achyranthes relieves the body of excess fluids and strengthens it. They hold that achyranthes strengthens the liver, kidneys, bones and tendons. It has been used for convalescence, comfort and certain gynecological needs.

            [Ingredients] => Concentrated extract of eucommia bark, cistanche stem, achyranthes root, dipsacus root, drynaria rhizome, hoelen sclerotium, morinda root, rehmannia root tuber, astragalus root, cornus fruit without seeds, dioscorea rhizome, epimedium leaf, ligustrum fruit, liquidamber fruit, lycium fruit, ginseng root, tang-kuei root and atractylodes rhizome.
            [RecommendedUse] => Take 1 capsule with a meal daily. NOTE: Pregnant or lactating women should consult their health care provider prior to taking this supplement.
            [Title] => KB-C TCM Conc. (30 caps)
            [Status] => Valid
            [PriceList] => Array
                (
                    [0] => Array
                        (
                            [Type] => QV
                            [Value] => 22.95
                        )

                    [1] => Array
                        (
                            [Type] => COST
                            [Value] => 22.95
                        )

                    [2] => Array
                        (
                            [Type] => RETAIL
                            [Value] => 34.45
                        )

                )

            [ImagePath] => \images\1016.jpg
            [ImageLable] => \labels\1016.jpg
            [PDF] => \pdfs\1016-0.pdf
            [Category] => 
            [SubCategory] => 
        )

    [9] => Array
        (
            [ID] => fc5822f9-1b31-44f7-baff-2cd8f93c3143
            [PublishDate] => 2013-08-05T22:22:25.2381661-04:00
            [SKU] => 1017
            [CheckDigit] => 1
            [Description] => Nervous Fatigue TCM Conc. (30 caps)
            [Benifits] => Array
                (
                    [0] => Relieves stress and promotes feelings of well-being.
                    [1] => Nourishes the circulatory and nervous systems.
                    [2] => Supports digestion.
                    [3] => Promotes sleep.
                    [4] => Invigorates the body.
                )

            [HowItWorks] => This TCM concentrate contains the same herbs found in Nervous Fatigue formula but in a highly concentrated blend. Traditional Chinese Medicine would consider this a fire-enhancing formula. Its Chinese name yang xin translates to “nurture the heart.” Weakness in the fire element usually manifests itself in the digestive, cardiovascular or reproductive systems. Biota seed contains aromatic compounds that have a sedative effect. These compounds also have a mild laxative effect. Jujuba seed contains bitter compounds that help promote relaxation. Schizandra fruit, a supporting herb in this formula, allows the body to respond quickly to stress, thus increasing the body’s capacity to work. Its bitter compounds also support circulation. Ginseng acts as an adaptogen to help maintain balance in the body and help the body adapt to stress.
            [Ingredients] => Concentrated extract of schizandra fruit, biota seed, cistanche stem, cuscuta seed, lycium fruit, ophiopogon root tuber, succinum amber, tang-kuei root, acorus rhizome, astragalus root, dioscorea rhizome, hoelen sclerotium, lotus seed, ginseng root, polygala root, polygonatum rhizome, jujuba seed and rehmannia root tuber. 
            [RecommendedUse] => Take one capsule with a meal daily. NOTE: Pregnant or lactating women should consult their health care provider prior to taking this supplement.
            [Title] => Nervous Fatigue TCM Conc. (30 caps)
            [Status] => Valid
            [PriceList] => Array
                (
                    [0] => Array
                        (
                            [Type] => QV
                            [Value] => 21.95
                        )

                    [1] => Array
                        (
                            [Type] => COST
                            [Value] => 21.95
                        )

                    [2] => Array
                        (
                            [Type] => RETAIL
                            [Value] => 32.95
                        )

                )

            [ImagePath] => \images\1017.jpg
            [ImageLable] => \labels\1017.jpg
            [PDF] => \pdfs\1017-1.pdf
            [Category] => 
            [SubCategory] => 
        )

Open in new window


Thanks for helping even on today.
0
 
LVL 42

Expert Comment

by:Chris Stanyon
ID: 39684289
OK. Because the Benefits data is an array, there are a couple of ways to deal with it.

You say you want it inserting into 1 record, so you will have to join the whole array into one string (I hope the table column is big enough to store the data!!).

The simplest way to do this is with the implode function - this will join all the values of an array into a single string, separated by a particular character.

Here's a very simple example of what you need. Tweak it to your needs:

<?php 
$jsonData = file_get_contents("data.json");
$phpArray = json_decode($jsonData, true);

$con = mysqli_connect("localhost","username","password","database");
 
foreach ($phpArray as $row) {
	$howItWorks = $row['HowItWorks'];
	$benefits = implode('|', $row['Benifits']);
		
	$sqlStr = sprintf("INSERT INTO ps_product_lang_test (howitworks, benefits) VALUES ('%s', '%s')", $howitworks, $benefits);	
	$result = mysqli_query($con, $sqlStr);
}
?>

Open in new window

0
 
LVL 20

Expert Comment

by:Mark Brady
ID: 39685529
I would recommend storing the values you need as a json string. That way you can keep associative arrays in tack. Try this example.

<?php
$filename = 'http://www.abc.com/abc.json';

if (!file_exists($filename)) {
    die('file not found for '.$filename); // can not find the file
}

// if we get here the file has been found
$filedata = file_get_contents($filename);

// try to decode it - if this does not work or it is not a valid Json string then the result will be null
$result = json_decode($filedata, true);

if (is_null($result)) die('not a valid json');

// ok so we now have an associative array to work with

// start your loop
foreach ($result as $entry) {
    // now the values you want to inset can be joined together here
    $insert_data = array(
        'Benifits' => $entry['Benifits'], // this is an array
        'HowItWorks' => $entry['HowItWorks'] // this is a string
        
        );
    // now you can insert the final data but json encode it first
    $insert_data = json_encode($insert_data); // ready to insert!
    
    // you insert statement goes here
}
?>

Open in new window

0
 

Author Comment

by:sharingsunshine
ID: 39685664
Hi Chris,

I made the changes to the mysql connection line and the location of the json file and it still doesn't do anything.  I only get a white screen.  I have this code at the top

error_reporting(E_ALL);
ini_set('display_errors', 1);

Open in new window


nothing is showing except for the misspelling of $howItWorks when I fixed that no errors show.  Any ideas?
0
 

Author Comment

by:sharingsunshine
ID: 39685775
Hi Elvin66,

Your example looks good and promising.  However, I am used to referencing an associative array so I need some help with the insert statment.  This is what I have tried

// you insert statement goes here
	$insert_data = sprintf("INSERT INTO ps_product_lang_test (description) VALUES ('%s')", $insert_data['Benifits']);	
	

Open in new window


I am only doing the Benifits content because I don't know how to pass both objects to one field in the DB and Benifits needs to be what is put in first.

Thanks,
0
 
LVL 20

Expert Comment

by:Mark Brady
ID: 39685823
Ok I thought you wanted to insert both the benifits value and the HowItWorks values into one field in your database table? If that is true then you can change your insert query to this.

$insert_data = sprintf("INSERT INTO ps_product_lang_test (description) VALUES ('%s')", $insert_data);

if you look at line 27 of my code example you will see that $insert_data is not an array anymore, it is a json string so you can go ahead and put that string directly into your field.

When you need to get it out you just do a select query on that field and when you get the data you json_decode($data, true); and you will have an associative array to work with again.
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

Author Comment

by:sharingsunshine
ID: 39685901
Hi Elvin66,

That is exactly what I want but it isn't updating the table.

CREATE TABLE `ps_product_lang_test` (
 `id_product` int(10) unsigned NOT NULL,
 `id_shop` int(11) unsigned NOT NULL default '1',
 `id_lang` int(10) unsigned NOT NULL,
 `description` text,
 `description_short` text,
 `link_rewrite` varchar(128) NOT NULL,
 `meta_description` varchar(255) default NULL,
 `meta_keywords` varchar(255) default NULL,
 `meta_title` varchar(128) default NULL,
 `name` varchar(128) NOT NULL,
 `available_now` varchar(255) default NULL,
 `available_later` varchar(255) default NULL,
 PRIMARY KEY  (`id_product`,`id_shop`,`id_lang`),
 KEY `id_lang` (`id_lang`),
 KEY `name` (`name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8

Open in new window


Here is the schema of the table to see if you can notice anything wrong with it.  The table has to stay within the cart guidelines.

Lastly, you mentioned this is going in as a json string.  Since it is json, will the shopping cart be able to access this table without having to change the code to decode it?

Thanks,
0
 
LVL 42

Expert Comment

by:Chris Stanyon
ID: 39686257
If you want all the Benefits text and the HowItWorks text written to one text field, then you will need to write it to the DB in a format that maintains the structure. JSON is a good example of this, but it does mean that when you then need to use the data again you will have to SELECT it from the database and the decode the JSON string before it will make any sense.

Do you want to add all the Benefits and the HowItWorks text to the Description column as one value??
0
 

Author Comment

by:sharingsunshine
ID: 39686396
I do need the Benifts and HowItWorks text as one value but this is a shopping cart and not convenient to alter the code and decode it each time the answer needs to be displayed.  So don't see how I can use the JSON approach that Elvin outlined.
0
 
LVL 42

Expert Comment

by:Chris Stanyon
ID: 39686523
If you don't want to decode the data, then you've got to come up with a format that you're happy to display the data in. This is your application so it's your choice. You could just concatenate all the values into one string or you could create a little snippet of HTML to store in the db. We can't really guess what you want so you're going to have to be specific.

Here's an example of creating HTML:

foreach ($phpArray as $row) {
   $description = '<ul>';
   $description .= '<li>' . $row['HowItWorks'] . '</li>';
   foreach ($row['Benifits'] as $benefit):
      $description .= '<li>' . $benefit . '</li>';
   endforeach;
   $description .= '</ul>';

   $sqlStr = sprintf("INSERT INTO ps_product_lang_test (description) VALUES ('%s')", $description);	
   $result = mysqli_query($con, $sqlStr);
}

Open in new window

That will create a UL containing all the values you need, which you can then just display straight from the database
0
 

Author Comment

by:sharingsunshine
ID: 39687027
Chris,

This is great just what I needed except I needed Benefits first and How It Works afterwards.  I tried to make the adjustments but I can get only one Benefit to print out on the screen and the HowItWorks works fine.  I think I could figure it out  if you  explained why you have the nested foreach in parenthesis and closed in a colon rather than the normal {.  I tried to find it online but to no avail.  

Here is my code
foreach ($phpArray as $row) {
	foreach ($row['Benifits'] as $benefit):
	$description = '<p><span class="heading">Benefits</span>';
      $description .= '<br />' .'&bull;'. '&nbsp;' . $benefit . '<br />';
	  $description .= '</p>';
	endforeach;
$description .= '<p><span class="heading">How It Works</span><br />';
   $description .= $row['HowItWorks'] ;
   $description .= '</p>';

   $sqlStr = sprintf("INSERT INTO ps_product_lang_test (description) VALUES ('%s')", $description);	
   $result = mysqli_query($con, $sqlStr);
   print_r ($sqlStr);
}

Open in new window


Still don't have it posting to MySQL but once I get the benefits working I'll close this out.  But if you have any troubleshooting suggestions please let me know.

Thanks,
0
 
LVL 42

Accepted Solution

by:
Chris Stanyon earned 500 total points
ID: 39687057
Using a colon at the end of a control structure is just an alternative way of working in PHP. I often use it if I have nested control structures so I can see exacly what's being ended and where. You can often end up with lots of closing } and not know which belongs to what structure. Here's afew alternatives:

foreach () {
...
}

foreach ():
...
endforeach;

if () {
...
}

if ():
...
endif;

while () {
...
}

while:
...
endwhile;

Open in new window

The reason your code is only giving you one benefit is because each time you loop through the benefits, you reset the $description variable, so only the last one gets used. Have a look at this:

foreach ($phpArray as $row) {
   $description = '<p><span class="heading">Benefits</span><br />';
   
   foreach ($row['Benifits'] as $benefit):
      $description .= '&bull;&nbsp;' . $benefit . '<br />';
   endforeach;

   $description .= '</p>';
   $description .= '<p><span class="heading">How It Works</span><br />';
   $description .= $row['HowItWorks'] ;
   $description .= '</p>';

   $sqlStr = sprintf("INSERT INTO ps_product_lang_test (description) VALUES ('%s')", $description);	
   $result = mysqli_query($con, $sqlStr);
   var_dump($sqlStr);
}

Open in new window

FYI - You might be better off using a UL for a bulleted list - that's what they're designed for
0
 

Author Closing Comment

by:sharingsunshine
ID: 39687187
Thanks for your help and willingness to explain rather than just give an answer.  You are one of the best experts I have worked with over the years.
0
 
LVL 42

Expert Comment

by:Chris Stanyon
ID: 39687201
Always happy to help :)

Good luck with your project...
0

Featured Post

Get up to 2TB FREE CLOUD per backup license!

An exclusive Black Friday offer just for Expert Exchange audience! Buy any of our top-rated backup solutions & get up to 2TB free cloud per system! Perform local & cloud backup in the same step, and restore instantly—anytime, anywhere. Grab this deal now before it disappears!

Join & Write a Comment

Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
This article discusses how to create an extensible mechanism for linked drop downs.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now