{"id":1478,"date":"2017-11-30T15:22:51","date_gmt":"2017-11-30T15:22:51","guid":{"rendered":"https:\/\/buyblueridgefood.com\/?page_id=1478"},"modified":"2017-11-30T15:22:51","modified_gmt":"2017-11-30T15:22:51","slug":"database-print-out","status":"publish","type":"page","link":"https:\/\/blueridgefood.com\/index.php\/database-print-out\/","title":{"rendered":"Database Print Out"},"content":{"rendered":"<p>[insert_php]<\/p>\n<p>  $servername = &#8220;localhost&#8221;;<br \/>\n  $username   = &#8220;blueridg_bridge&#8221;;<br \/>\n  $password   = &#8220;kr~COSJQ7DP5&#8221;;<br \/>\n  $dbname     = &#8220;blueridg_bridge&#8221;;<\/p>\n<p>  $priceType   = &#8220;regular_price&#8221;;<\/p>\n<p>  \/\/ Create connection<br \/>\n  $conn = mysqli_connect($servername, $username, $password, $dbname);<br \/>\n  if( mysqli_connect_errno() ){<br \/>\n    echo &#8220;Database Error: &#8220;.mysqli_connect_errno();<br \/>\n  }else{<br \/>\n    $sql = &#8220;SELECT name, packaging, &#8220;.$priceType.&#8221; AS price, promoting, category  FROM bridge_products ORDER BY category, name ASC&#8221;;<\/p>\n<p>    if($result = mysqli_query($conn, $sql)){<br \/>\n      while($row = mysqli_fetch_assoc($result)){<br \/>\n        if($category){<br \/>\n          if($category != $row[&#8216;category&#8217;]){<br \/>\n            $category = $row[&#8216;category&#8217;];<br \/>\n            echo &#8216;<\/table>\n<h3>&#8216;.ucfirst($category).&#8217;<\/h3>\n<table>\n<tr>\n<td>Item<\/td>\n<td>Packaging<\/td>\n<td>Price<\/td>\n<\/tr>\n<p>&#8216;;<br \/>\n          }<br \/>\n        }else{<br \/>\n          $category = $row[&#8216;category&#8217;];<br \/>\n          echo &#8216;<\/p>\n<h3>&#8216;.ucfirst($category).&#8217;<\/h3>\n<table>\n<tr>\n<td>Item<\/td>\n<td>Packaging<\/td>\n<td>Price<\/td>\n<\/tr>\n<p>&#8216;;<br \/>\n        }<br \/>\n        echo &#8216;<\/p>\n<tr>\n<td>&#8216;.$row[&#8216;name&#8217;].&#8217;<\/td>\n<td>&#8216;.$row[&#8216;packaging&#8217;].&#8217;<\/td>\n<td>&#8216;;<br \/>\n        if( $row[&#8216;price&#8217;] ){<br \/>\n          echo &#8216;&#36;&#8217;.money_format(&#8216;%i&#8217;, doubleval($row[&#8216;price&#8217;]));<br \/>\n        }else{<br \/>\n          echo $row[&#8216;price&#8217;];<br \/>\n        }<br \/>\n        echo &#8216;<\/td>\n<\/tr>\n<p>&#8216;;<br \/>\n      }<br \/>\n      echo &#8216;<\/table>\n<p>&#8216;;<br \/>\n    }<br \/>\n  }<\/p>\n<p>[\/insert_php]<\/p>\n","protected":false},"excerpt":{"rendered":"<p>[insert_php] $servername = &#8220;localhost&#8221;; $username = &#8220;blueridg_bridge&#8221;; $password = &#8220;kr~COSJQ7DP5&#8221;; $dbname = &#8220;blueridg_bridge&#8221;; $priceType = &#8220;regular_price&#8221;; \/\/ Create connection $conn = mysqli_connect($servername, $username, $password, $dbname); if( mysqli_connect_errno() ){ echo &#8220;Database Error: &#8220;.mysqli_connect_errno(); }else{ $sql = &#8220;SELECT name, packaging, &#8220;.$priceType.&#8221; AS price, promoting, category FROM bridge_products ORDER BY category, name ASC&#8221;; if($result = mysqli_query($conn, $sql)){ while($row&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-1478","page","type-page","status-publish","hentry","no-sidebar"],"_links":{"self":[{"href":"https:\/\/blueridgefood.com\/index.php\/wp-json\/wp\/v2\/pages\/1478","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blueridgefood.com\/index.php\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/blueridgefood.com\/index.php\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/blueridgefood.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blueridgefood.com\/index.php\/wp-json\/wp\/v2\/comments?post=1478"}],"version-history":[{"count":0,"href":"https:\/\/blueridgefood.com\/index.php\/wp-json\/wp\/v2\/pages\/1478\/revisions"}],"wp:attachment":[{"href":"https:\/\/blueridgefood.com\/index.php\/wp-json\/wp\/v2\/media?parent=1478"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}