title: JSON into MYSQL TABLE with PHP
body: <p>Trying to Insert the JSON File into MYSQL TABLE using PHP, Trying to loop through the JSON File but it just inserts the first row, I am a beginner so please help, below is my PHP code</p>
  <pre><code>$host = &quot;localhost&quot;;
  $username = &quot;root&quot;;
  $password = &quot;&quot;;
  $dbname = &quot;Portfolio&quot;;
  $con = mysqli_connect($host, $username, $password, $dbname) or die('Error in Connecting: ' . mysqli_error($con));
  
  
  $st = mysqli_prepare($con, 'INSERT INTO completetsxtickers (summaryDetailmaxAge,summaryDetailpriceHint,summaryDetailpreviousClose,summaryDetailopen,
                      summaryDetaildayLow,summaryDetaildayHigh,summaryDetailregularMarketPreviousClose,summaryDetailregularMarketOpen,summaryDetailregularMarketDayLow,
                      summaryDetailregularMarketDayHigh,summaryDetaildividendRate,summaryDetaildividendYield,summaryDetailexDividendDate,summaryDetailpayoutRatio,
                      summaryDetailfiveYearAvgDividendYield,summaryDetailbeta,summaryDetailtrailingPE,summaryDetailforwardPE,summaryDetailvolume,
                      summaryDetailregularMarketVolume,summaryDetailaverageVolume,summaryDetailaverageVolume10days,summaryDetailaverageDailyVolume10Day,summaryDetailbid,
                      summaryDetailask,summaryDetailbidSize,summaryDetailaskSize,summaryDetailmarketCap,summaryDetailfiftyTwoWeekLow,summaryDetailfiftyTwoWeekHigh,
                      summaryDetailpriceToSalesTrailing12Months,summaryDetailfiftyDayAverage,summaryDetailtwoHundredDayAverage,summaryDetailtrailingAnnualDividendRate,
                      summaryDetailtrailingAnnualDividendYield,summaryDetailcurrency,summaryDetailfromCurrency,summaryDetaillastMarket,summaryDetailalgorithm,
                      summaryDetailtradeable,pricemaxAge,priceregularMarketChangePercent,priceregularMarketChange,priceregularMarketTime,pricepriceHint,
                      priceregularMarketPrice,priceregularMarketDayHigh,priceregularMarketDayLow,priceregularMarketVolume,priceaverageDailyVolume10Day,
                      priceaverageDailyVolume3Month,priceregularMarketPreviousClose,priceregularMarketSource,priceregularMarketOpen,priceexchange,priceexchangeName,
                      priceexchangeDataDelayedBy,pricemarketState,pricequoteType,pricesymbol,priceunderlyingSymbol,priceshortName,pricelongName,pricecurrency,
                      pricequoteSourceName,pricecurrencySymbol,pricefromCurrency,pricelastMarket,pricemarketCap)
                                 VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 
                                         ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 
                                         ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)');
  
  // bind variables to insert query params
  
  mysqli_stmt_bind_param($st, 'sssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss', $summaryDetailmaxAge,$summaryDetailpriceHint,
      $summaryDetailpreviousClose,$summaryDetailopen,
      $summaryDetaildayLow,$summaryDetaildayHigh,$summaryDetailregularMarketPreviousClose,$summaryDetailregularMarketOpen,$summaryDetailregularMarketDayLow,
      $summaryDetailregularMarketDayHigh,$summaryDetaildividendRate,$summaryDetaildividendYield,$summaryDetailexDividendDate,$summaryDetailpayoutRatio,
      $summaryDetailfiveYearAvgDividendYield,$summaryDetailbeta,$summaryDetailtrailingPE,$summaryDetailforwardPE,$summaryDetailvolume,
      $summaryDetailregularMarketVolume,$summaryDetailaverageVolume,$summaryDetailaverageVolume10days,$summaryDetailaverageDailyVolume10Day,$summaryDetailbid,
      $summaryDetailask,$summaryDetailbidSize,$summaryDetailaskSize,$summaryDetailmarketCap,$summaryDetailfiftyTwoWeekLow,$summaryDetailfiftyTwoWeekHigh,
      $summaryDetailpriceToSalesTrailing12Months,$summaryDetailfiftyDayAverage,$summaryDetailtwoHundredDayAverage,$summaryDetailtrailingAnnualDividendRate,
      $summaryDetailtrailingAnnualDividendYield,$summaryDetailcurrency,$summaryDetailfromCurrency,$summaryDetaillastMarket,$summaryDetailalgorithm,
      $summaryDetailtradeable,$pricemaxAge,$priceregularMarketChangePercent,$priceregularMarketChange,$priceregularMarketTime,$pricepriceHint,
      $priceregularMarketPrice,$priceregularMarketDayHigh,$priceregularMarketDayLow,$priceregularMarketVolume,$priceaverageDailyVolume10Day,
      $priceaverageDailyVolume3Month,$priceregularMarketPreviousClose,$priceregularMarketSource,$priceregularMarketOpen,$priceexchange,$priceexchangeName,
      $priceexchangeDataDelayedBy,$pricemarketState,$pricequoteType,$pricesymbol,$priceunderlyingSymbol,$priceshortName,$pricelongName,$pricecurrency,
      $pricequoteSourceName,$pricecurrencySymbol,$pricefromCurrency,$pricelastMarket,$pricemarketCap);
  
  $filename = 'testing.json';
  
  $json = file_get_contents($filename);
  
  $data = json_decode($json, true);
  
  var_dump($data);
  
  foreach ($data as $row)
  {
  
      $summaryDetailmaxAge = $row['summaryDetail']['maxAge'];
      $summaryDetailpriceHint = $row['summaryDetail']['priceHint'];
      $summaryDetailpreviousClose = $row['summaryDetail']['previousClose'];
      $summaryDetailopen = $row['summaryDetail']['open'];
      $summaryDetaildayLow = $row['summaryDetail']['dayLow'];
      ....
      ....
      
  
      mysqli_stmt_execute($st);
  
  }
  </code></pre>
  <p>MY JSON File below, cant seem to loop through it, its a list of Tickers and values which I am trying to insert into a MYSQL Table</p>
  <pre><code>       {
      &quot;AC.TO&quot;: {
          &quot;summaryDetail&quot;: {
            &quot;maxAge&quot;: 1,
            &quot;priceHint&quot;: 2,
            &quot;previousClose&quot;: 25.5,
            &quot;open&quot;: 25.83,
            &quot;dayLow&quot;: 25.2,
            &quot;dayHigh&quot;: 25.9,
            &quot;regularMarketPreviousClose&quot;: 25.5,
            &quot;regularMarketOpen&quot;: 25.83,
            &quot;regularMarketDayLow&quot;: 25.2,
            &quot;regularMarketDayHigh&quot;: 25.9,
            &quot;payoutRatio&quot;: 0,
            &quot;beta&quot;: 2.481872,
            &quot;forwardPE&quot;: -103.56,
            &quot;volume&quot;: 2536872,
            &quot;regularMarketVolume&quot;: 2536872,
            &quot;averageVolume&quot;: 3607496,
            &quot;averageVolume10days&quot;: 2868300,
            &quot;averageDailyVolume10Day&quot;: 2868300,
            &quot;bid&quot;: 25.51,
            &quot;ask&quot;: 25.52,
            &quot;bidSize&quot;: 0,
            &quot;askSize&quot;: 0,
            &quot;marketCap&quot;: 8666910720,
            &quot;fiftyTwoWeekLow&quot;: 14.48,
            &quot;fiftyTwoWeekHigh&quot;: 31,
            &quot;priceToSalesTrailing12Months&quot;: 3.0517292,
            &quot;fiftyDayAverage&quot;: 26.889706,
            &quot;twoHundredDayAverage&quot;: 25.156204,
            &quot;currency&quot;: &quot;CAD&quot;,
            &quot;fromCurrency&quot;: null,
            &quot;lastMarket&quot;: null,
            &quot;algorithm&quot;: null,
            &quot;tradeable&quot;: false
          },
          &quot;price&quot;: {
            &quot;maxAge&quot;: 1,
            &quot;regularMarketChangePercent&quot;: 0.015294094,
            &quot;regularMarketChange&quot;: 0.3899994,
            &quot;regularMarketTime&quot;: &quot;2021-07-02 13:00:00&quot;,
            &quot;priceHint&quot;: 2,
            &quot;regularMarketPrice&quot;: 25.89,
            &quot;regularMarketDayHigh&quot;: 25.9,
            &quot;regularMarketDayLow&quot;: 25.2,
            &quot;regularMarketVolume&quot;: 2536872,
            &quot;averageDailyVolume10Day&quot;: 2868300,
            &quot;averageDailyVolume3Month&quot;: 3607496,
            &quot;regularMarketPreviousClose&quot;: 25.5,
            &quot;regularMarketSource&quot;: &quot;FREE_REALTIME&quot;,
            &quot;regularMarketOpen&quot;: 25.83,
            &quot;exchange&quot;: &quot;TOR&quot;,
            &quot;exchangeName&quot;: &quot;Toronto&quot;,
            &quot;exchangeDataDelayedBy&quot;: 15,
            &quot;marketState&quot;: &quot;CLOSED&quot;,
            &quot;quoteType&quot;: &quot;EQUITY&quot;,
            &quot;symbol&quot;: &quot;AC.TO&quot;,
            &quot;underlyingSymbol&quot;: null,
            &quot;shortName&quot;: &quot;AIR CANADA&quot;,
            &quot;longName&quot;: &quot;Air Canada&quot;,
            &quot;currency&quot;: &quot;CAD&quot;,
            &quot;quoteSourceName&quot;: &quot;Delayed Quote&quot;,
            &quot;currencySymbol&quot;: &quot;$&quot;,
            &quot;fromCurrency&quot;: null,
            &quot;lastMarket&quot;: null,
            &quot;marketCap&quot;: 8666910720
          }
        },
      &quot;SCR.TO&quot;: {
          &quot;summaryDetail&quot;: {
            &quot;maxAge&quot;: 1,
            &quot;priceHint&quot;: 2,
            &quot;previousClose&quot;: 24.86,
            &quot;open&quot;: 25.24,
            &quot;dayLow&quot;: 23.59,
            &quot;dayHigh&quot;: 24.94,
            &quot;regularMarketPreviousClose&quot;: 24.86,
            &quot;regularMarketOpen&quot;: 25.24,
            &quot;regularMarketDayLow&quot;: 23.59,
            &quot;regularMarketDayHigh&quot;: 24.94,
            &quot;payoutRatio&quot;: 0,
            &quot;beta&quot;: 2.638101,
            &quot;forwardPE&quot;: -40.28814,
            &quot;volume&quot;: 187927,
            &quot;regularMarketVolume&quot;: 187927,
            &quot;averageVolume&quot;: 389974,
            &quot;averageVolume10days&quot;: 686057,
            &quot;averageDailyVolume10Day&quot;: 686057,
            &quot;bid&quot;: 24.72,
            &quot;ask&quot;: 24.76,
            &quot;marketCap&quot;: 1196655488,
            &quot;fiftyTwoWeekLow&quot;: 5.5,
            &quot;fiftyTwoWeekHigh&quot;: 56.7,
            &quot;priceToSalesTrailing12Months&quot;: 63.048233,
            &quot;fiftyDayAverage&quot;: 22.763824,
            &quot;twoHundredDayAverage&quot;: 27.056059,
            &quot;currency&quot;: &quot;CAD&quot;,
            &quot;fromCurrency&quot;: null,
            &quot;lastMarket&quot;: null,
            &quot;algorithm&quot;: null,
            &quot;tradeable&quot;: false
          },
          &quot;price&quot;: {
            &quot;maxAge&quot;: 1,
            &quot;regularMarketChangePercent&quot;: -0.043845546,
            &quot;regularMarketChange&quot;: -1.0900002,
            &quot;regularMarketTime&quot;: &quot;2021-07-02 13:00:00&quot;,
            &quot;priceHint&quot;: 2,
            &quot;regularMarketPrice&quot;: 23.77,
            &quot;regularMarketDayHigh&quot;: 24.94,
            &quot;regularMarketDayLow&quot;: 23.59,
            &quot;regularMarketVolume&quot;: 187927,
            &quot;averageDailyVolume10Day&quot;: 686057,
            &quot;averageDailyVolume3Month&quot;: 389974,
            &quot;regularMarketPreviousClose&quot;: 24.86,
            &quot;regularMarketSource&quot;: &quot;FREE_REALTIME&quot;,
            &quot;regularMarketOpen&quot;: 25.24,
            &quot;exchange&quot;: &quot;TOR&quot;,
            &quot;exchangeName&quot;: &quot;Toronto&quot;,
            &quot;exchangeDataDelayedBy&quot;: 15,
            &quot;marketState&quot;: &quot;CLOSED&quot;,
            &quot;quoteType&quot;: &quot;EQUITY&quot;,
            &quot;symbol&quot;: &quot;SCR.TO&quot;,
            &quot;underlyingSymbol&quot;: null,
            &quot;shortName&quot;: &quot;SCORE MEDIA AND GAMING INC&quot;,
            &quot;longName&quot;: &quot;Score Media and Gaming Inc.&quot;,
            &quot;currency&quot;: &quot;CAD&quot;,
            &quot;quoteSourceName&quot;: &quot;Delayed Quote&quot;,
            &quot;currencySymbol&quot;: &quot;$&quot;,
            &quot;fromCurrency&quot;: null,
            &quot;lastMarket&quot;: null,
            &quot;marketCap&quot;: 1196655488
          }
        }
      }
  </code></pre>