i'm using codeigniter for create a web site. and i need to take result from mysql table as
this
object(mysqli_result)#2 (5) { ["current_field"]=> int(0) ["field_count"]=> int(4) ["lengths"]=> NULL ["num_rows"]=> int(12) ["type"]=> int(0) }
but always i got as a result something efferent from this.
when i'm using result_object() in codeigniter i'm getting something like this
array(12) { [0]=> object(stdClass)#24 (4) { ["id"]=> string(1) "1" ["label"]=> string(15) "Web Development" ["link_url"]=> string(0) "" ["parent_id"]=> string(1) "0" } [1]=> object(stdClass)#25 (4) { ["id"]=> string(2) "10" ["label"]=> string(19) "Sales and Marketing" ["link_url"]=> string(0) "" ["parent_id"]=> string(1) "0" } [2]=> object(stdClass)#26 (4) { ["id"]=> string(1) "7" ["label"]=> string(18) "Design and Artwork" ["link_url"]=> string(0) "" ["parent_id"]=> string(1) "0" } [3]=> object(stdClass)#27 (4) { ["id"]=> string(1) "2" ["label"]=> string(16) "Content Creation" ["link_url"]=> string(0) "" ["parent_id"]=> string(1) "0" } [4]=> object(stdClass)#28 (4) { ["id"]=> string(1) "4" ["label"]=> string(19) "OSCommerce projects" ["link_url"]=> string(29) "/php_web_development_jobs.php" ["parent_id"]=> string(1) "1" } [5]=> object(stdClass)#29 (4) { ["id"]=> string(1) "3" ["label"]=> string(8) "PHP Jobs" ["link_url"]=> string(29) "/php_web_development_jobs.php" ["parent_id"]=> string(1) "1" } [6]=> object(stdClass)#30 (4) { ["id"]=> string(1) "5" ["label"]=> string(22) "Technical Writing Jobs" ["link_url"]=> string(29) "/php_web_development_jobs.php" ["parent_id"]=> string(1) "2" } [7]=> object(stdClass)#31 (4) { ["id"]=> string(1) "6" ["label"]=> string(13) "Forum Posting" ["link_url"]=> string(29) "/php_web_development_jobs.php" ["parent_id"]=> string(1) "2" } [8]=> object(stdClass)#32 (4) { ["id"]=> string(1) "8" ["label"]=> string(20) "Blog Design Projects" ["link_url"]=> string(29) "/php_web_development_jobs.php" ["parent_id"]=> string(1) "7" } [9]=> object(stdClass)#33 (4) { ["id"]=> string(1) "9" ["label"]=> string(24) "Freelance Website Design" ["link_url"]=> string(29) "/php_web_development_jobs.php" ["parent_id"]=> string(1) "7" } [10]=> object(stdClass)#34 (4) { ["id"]=> string(2) "11" ["label"]=> string(29) "Internet Marketing Consulting" ["link_url"]=> string(29) "/php_web_development_jobs.php" ["parent_id"]=> string(2) "10" } [11]=> object(stdClass)#35 (4) { ["id"]=> string(2) "12" ["label"]=> string(25) "Leads Generation Services" ["link_url"]=> string(29) "/php_web_development_jobs.php" ["parent_id"]=> string(2) "10" } }
$this->db->order_by('parent_id','id','ASC');
$query = $this->db->get('dyn_menu');
if ($query->num_rows() > 0) {
$data = $query->result_object();
return $data;
}
how can i get the result as i want?
try using just result(), like:
...
$data = $query->result();
return $data;
...
try this if single record you want, make $is_single = true
if($is_single)
return $query ->row_array();
else
return $query ->result_array();
Related
I would like to get subcategory and main category from this arrays which I give below. First I want to get category and then would like to show subcategory under main category.
I have tried this PHP code but unfortunately my code doesn't work which I want. Can you suggest me another code please?
<?php
$resp = $c->execute($req);
var_dump($c->execute($req));
output:
object(SimpleXMLElement)#6 (2) {
["resp_result"]=>
object(SimpleXMLElement)#3 (3) {
["resp_code"]=>
string(3) "200"
["resp_msg"]=>
string(13) "Call succeeds"
["result"]=>
object(SimpleXMLElement)#4 (2) {
["categories"]=>
object(SimpleXMLElement)#7 (1) {
["category"]=>
array(499) {
[0]=>
object(SimpleXMLElement)#8 (2) {
["category_id"]=>
string(1) "2"
["category_name"]=>
string(4) "Food"
}
[1]=>
object(SimpleXMLElement)#9 (3) {
["category_id"]=>
string(9) "201379402"
["category_name"]=>
string(4) "Meat"
["parent_category_id"]=>
string(1) "2"
}
[2]=>
object(SimpleXMLElement)#10 (3) {
["category_id"]=>
string(9) "201379801"
["category_name"]=>
string(18) "Fruits and Berries"
["parent_category_id"]=>
string(1) "2"
}
[3]=>
object(SimpleXMLElement)#11 (3) {
["category_id"]=>
string(9) "201378002"
["category_name"]=>
string(18) "Bread and Pastries"
["parent_category_id"]=>
string(1) "2"
}
[4]=>
object(SimpleXMLElement)#12 (3) {
["category_id"]=>
string(9) "201248407"
["category_name"]=>
string(11) "Canned Food"
["parent_category_id"]=>
string(1) "2"
}
[5]=>
object(SimpleXMLElement)#13 (3) {
["category_id"]=>
string(9) "201378103"
["category_name"]=>
string(8) "Sausages"
["parent_category_id"]=>
string(1) "2"
}
[6]=>
object(SimpleXMLElement)#14 (3) {
["category_id"]=>
string(9) "200183144"
["category_name"]=>
string(12) "Canned Food1"
["parent_category_id"]=>
string(1) "2"
}
[7]=>
object(SimpleXMLElement)#15 (3) {
["category_id"]=>
string(9) "201345805"
["category_name"]=>
string(19) "Alcoholic Beverages"
["parent_category_id"]=>
string(1) "2"
}
[8]=>
object(SimpleXMLElement)#16 (3) {
["category_id"]=>
string(9) "201376903"
["category_name"]=>
string(17) "Fish and Sea Food"
["parent_category_id"]=>
string(1) "2"
}
[9]=>
object(SimpleXMLElement)#17 (3) {
["category_id"]=>
string(9) "200180142"
["category_name"]=>
string(7) "Grocery"
["parent_category_id"]=>
string(1) "2"
}
[10]=>
object(SimpleXMLElement)#18 (3) {
["category_id"]=>
string(9) "200001321"
["category_name"]=>
string(13) "Nut & Kernel1"
["parent_category_id"]=>
string(1) "2"
}
[11]=>
object(SimpleXMLElement)#19 (3) {
["category_id"]=>
string(9) "200001317"
["category_name"]=>
string(12) "Dried Fruit1"
["parent_category_id"]=>
string(1) "2"
}
[12]=>
object(SimpleXMLElement)#20 (3) {
["category_id"]=>
string(9) "200001287"
["category_name"]=>
string(15) "Grain Products1"
["parent_category_id"]=>
string(1) "2"
}
[13]=>
object(SimpleXMLElement)#21 (3) {
["category_id"]=>
string(9) "200001238"
["category_name"]=>
string(7) "Coffee1"
["parent_category_id"]=>
string(1) "2"
}
[14]=>
object(SimpleXMLElement)#22 (3) {
["category_id"]=>
string(9) "201376204"
["category_name"]=>
string(13) "Milk and Eggs"
["parent_category_id"]=>
string(1) "2"
}
[15]=>
object(SimpleXMLElement)#23 (3) {
["category_id"]=>
string(9) "201376702"
["category_name"]=>
string(10) "Ready Meal"
["parent_category_id"]=>
string(1) "2"
}
[16]=>
object(SimpleXMLElement)#24 (3) {
["category_id"]=>
string(9) "201249506"
["category_name"]=>
string(21) "Water/ Juices/ Drinks"
["parent_category_id"]=>
string(1) "2"
}
[17]=>
object(SimpleXMLElement)#25 (3) {
["category_id"]=>
string(9) "201248805"
["category_name"]=>
string(31) "Dried Goods / Local Specialties"
["parent_category_id"]=>
string(1) "2"
}
[18]=>
object(SimpleXMLElement)#26 (3) {
["category_id"]=>
string(9) "201248804"
["category_name"]=>
string(6) "Coffee"
["parent_category_id"]=>
string(1) "2"
}
[19]=>
object(SimpleXMLElement)#27 (3) {
["category_id"]=>
string(9) "200003573"
["category_name"]=>
string(32) "Dried Goods / Local Specialties1"
["parent_category_id"]=>
string(1) "2"
}
[20]=>
object(SimpleXMLElement)#28 (3) {
["category_id"]=>
string(9) "201379901"
["category_name"]=>
string(6) "Cheese"
["parent_category_id"]=>
string(1) "2"
}
[21]=>
object(SimpleXMLElement)#29 (3) {
["category_id"]=>
string(9) "201254404"
["category_name"]=>
string(11) "Dried Fruit"
["parent_category_id"]=>
string(1) "2"
}
[22]=>
object(SimpleXMLElement)#30 (3) {
["category_id"]=>
string(9) "201254306"
["category_name"]=>
string(14) "Grain Products"
["parent_category_id"]=>
string(1) "2"
}
[23]=>
object(SimpleXMLElement)#31 (3) {
["category_id"]=>
string(9) "201253905"
["category_name"]=>
string(12) "Nut & Kernel"
["parent_category_id"]=>
string(1) "2"
}
[24]=>
object(SimpleXMLElement)#32 (3) {
["category_id"]=>
string(9) "201374104"
["category_name"]=>
string(15) "Frozen Products"
["parent_category_id"]=>
string(1) "2"
}
[25]=>
object(SimpleXMLElement)#33 (3) {
["category_id"]=>
string(9) "100007269"
["category_name"]=>
string(3) "Tea"
["parent_category_id"]=>
string(1) "2"
}
[26]=>
object(SimpleXMLElement)#34 (3) {
["category_id"]=>
string(9) "201373004"
["category_name"]=>
string(21) "Vegetables and Greens"
["parent_category_id"]=>
string(1) "2"
}
[27]=>
object(SimpleXMLElement)#35 (2) {
["category_id"]=>
string(1) "3"
["category_name"]=>
string(21) "Apparel & Accessories"
}
[28]=>
object(SimpleXMLElement)#36 (3) {
["category_id"]=>
string(9) "200003274"
["category_name"]=>
string(11) "Sportswears"
["parent_category_id"]=>
string(1) "3"
}
[29]=>
object(SimpleXMLElement)#37 (2) {
["category_id"]=>
string(1) "6"
["category_name"]=>
string(15) "Home Appliances"
}
[30]=>
object(SimpleXMLElement)#38 (3) {
["category_id"]=>
string(3) "628"
["category_name"]=>
string(21) "Other Home Appliances"
["parent_category_id"]=>
string(1) "6"
}
}
}
["total_result_count"]=>
string(3) "499"
}
}
["request_id"]=>
string(13) "15r9xetbc5h1i"
}
I mean:
Main category -> Food
Subcategory-> Meat
-> Fruits and Berries
Main category -> Apparel & Accessories
Subcategory -> Sportswears
Here is my foreach code:
foreach($CategoryResp->resp_result->result->categories->category as $cat){
if(isset($cat->parent_category_id->string) == 'NUL'){
//mother category
echo "<b>".$cat->category_id. ' '.$cat->category_name."</b><br />";
if(isset($cat->parent_category_id)){
//subcategories
echo $cat->category_id. ' '.$cat->category_name."<br />";
}
}
}
First sorry for my English.
I have a weird problem using the php $_SESSION Object.
I spent 2 days without find the solution.
I am triying to save a multidimensional array that stores some post values.
I create an array with this values and then i create a multidimensional array containing this arrays.
Page 1 (setvalues in multi array ans save in session)-> GET -> Page 2 read the session.
My code Page 1:
First, save the post values into a object property and validate them.
public function validateData(){
$this->nombres=$_POST["nombre"];
$this->imp_nombres=$_POST["imp_nombre"];
$this->numeros=$_POST["numero"];
$this->imp_numeros=$_POST["imp_numero"];
$this->tallas=$_POST["talla"];
$this->cantidades=$_POST["cantidad"];
$this->productos=$_POST["products"];
$this->equipos=$_POST["equipo"];
if(WSI_Funtions::compareSizes($this->nombres,$this->imp_nombres,$this->numeros,$this->imp_numeros,$this->tallas,$this->cantidades,$this->productos,$this->equipos))
{
$this->isValidModel=true;
$this->saveProductsValues();
}
else{
$this->isValidModel=false;
$this->errorMessage="Los datos no son correctos. Los parametros no coinciden";
}
}
If data is ok, I save those values:
public function saveProductsValues()
{
$this->productsValues=array();
$this->productsValues["names"]=$this->nombres;
$this->productsValues["imp_nombres"]=$this->imp_nombres;
$this->productsValues["numeros"]=$this->numeros;
$this->productsValues["imp_numeros"]=$this->imp_numeros;
$this->productsValues["tallas"]=$this->tallas;
$this->productsValues["cantidades"]=$this->cantidades;
$this->productsValues["productos"]=$this->productos;
$this->productsValues["equipos"]=$this->equipos;
}
Then I save it in a session :
public function saveSessionValues()
{
$_SESSION['customer'] = $this->customerObject;
$_SESSION['productsValues'] =$this->productsValues;
echo var_dump($_SESSION['productsValues']);
}
The saveSessionValues echo print this:
array(8) { ["names"]=> array(12) { [0]=> string(0) "" [1]=> string(12) "ÁNGEL HDEZ." [2]=> string(11) "VUJASINOVIC" [3]=> string(4) "ABIA" [4]=> string(10) "MUTAKABBIR" [5]=> string(8) "PETROVIC" [6]=> string(5) "DOBOS" [7]=> string(4) "HOMS" [8]=> string(6) "CASTRO" [9]=> string(0) "" [10]=> string(0) "" [11]=> string(0) "" } ["imp_nombres"]=> array(12) { [0]=> string(0) "" [1]=> string(1) "1" [2]=> string(1) "1" [3]=> string(1) "1" [4]=> string(1) "1" [5]=> string(1) "1" [6]=> string(1) "1" [7]=> string(1) "1" [8]=> string(1) "1" [9]=> string(0) "" [10]=> string(0) "" [11]=> string(0) "" } ["numeros"]=> array(12) { [0]=> string(1) "7" [1]=> string(1) "8" [2]=> string(1) "9" [3]=> string(0) "" [4]=> string(2) "11" [5]=> string(2) "12" [6]=> string(2) "18" [7]=> string(2) "19" [8]=> string(2) "22" [9]=> string(1) "5" [10]=> string(2) "33" [11]=> string(0) "" } ["imp_numeros"]=> array(12) { [0]=> string(1) "1" [1]=> string(1) "1" [2]=> string(1) "1" [3]=> string(0) "" [4]=> string(1) "1" [5]=> string(1) "1" [6]=> string(1) "1" [7]=> string(1) "1" [8]=> string(1) "1" [9]=> string(1) "1" [10]=> string(1) "1" [11]=> string(0) "" } ["tallas"]=> array(12) { [0]=> string(4) "XXXL" [1]=> string(3) "XXL" [2]=> string(2) "XL" [3]=> string(3) "XXL" [4]=> string(3) "XXL" [5]=> string(3) "XXL" [6]=> string(4) "XXXL" [7]=> string(3) "XXL" [8]=> string(2) "XL" [9]=> string(4) "XXXL" [10]=> string(2) "XL" [11]=> string(3) "XXL" } ["cantidades"]=> array(12) { [0]=> string(1) "1" [1]=> string(1) "1" [2]=> string(1) "1" [3]=> string(1) "1" [4]=> string(3) "145" [5]=> string(1) "1" [6]=> string(1) "1" [7]=> string(1) "1" [8]=> string(1) "1" [9]=> string(1) "1" [10]=> string(1) "1" [11]=> string(1) "1" } ["productos"]=> array(12) { [0]=> string(3) "109" [1]=> string(3) "109" [2]=> string(3) "109" [3]=> string(3) "109" [4]=> string(3) "109" [5]=> string(3) "109" [6]=> string(3) "109" [7]=> string(3) "109" [8]=> string(3) "109" [9]=> string(3) "109" [10]=> string(3) "109" [11]=> string(3) "109" } ["equipos"]=> array(12) { [0]=> string(7) "LEB ORO" [1]=> string(7) "LEB ORO" [2]=> string(7) "LEB ORO" [3]=> string(7) "LEB ORO" [4]=> string(7) "LEB ORO" [5]=> string(7) "LEB ORO" [6]=> string(12) "ES TALLA 4XL" [7]=> string(7) "LEB ORO" [8]=> string(7) "LEB ORO" [9]=> string(12) "ES TALLA 4XL" [10]=> string(7) "LEB ORO" [11]=> string(7) "LEB ORO" } }
My code Page 2 (php tags ommitted):
if (!isset($_SESSION)) { session_start(); }
echo var_dump($_SESSION['productsValues']);
This echo print the next value:
array(8) { ["names"]=> NULL ["imp_nombres"]=> NULL ["numeros"]=> NULL ["imp_numeros"]=> NULL ["tallas"]=> NULL ["cantidades"]=> NULL ["productos"]=> NULL ["equipos"]=> NULL }
The first level array exists, because the subarrays keys are printed, but all the second level arrays are NULL..
Maybe is for use the $_POST value??
I had try to encode the values of the $_POST object, saving only a json string instead of saving a object with the same result, the first nodes in the JSON are the keys of the arrays but the values are "NULL"
Any help please??
Thanks!!
You are over writing the values. Try with -
$_SESSION['productsValues'][] = $this->productsValues;
i have an array with size=1 and when i try to get the current array its returns false but the array has values.
$article=getArticle($id);
if(is_array($article))
{ $article=current($article); }
the getArticle returns multidimensional array and when var_dump before current i can see the array.
If var_dump after current i get false.
if i use the code above (because the array size=1)
if(is_array($article))
{
foreach($article as $k=>$v)
{
$article=$v;
}
}
It works without any problem
Whats wrong with current?
Please help
===============EDIT========================
This is the var_dump before current
I have remove the content and summary because are large texts
array(1) {
[529]=>
array(14) {
["articles_id"]=>
string(3) "529"
["issue"]=>
string(3) "161"
["membership_type"]=>
string(1) "1"
["el"]=>
array(9) {
["title"]=>
string(23) "AUTOBIANCHI A112 ABARTH"
["url"]=>
string(23) "autobianchi-a112-abarth"
["summary"]=>
string(397) " i have remove it
"
["content"]=>
string(11580) " i have remove it too large
"
["meta_keywords"]=>
string(23) "AUTOBIANCHI,A112,ABARTH"
["meta_description"]=>
string(402) " "
["created"]=>
string(10) "1362076380"
["last_updated"]=>
string(1) "0"
["status"]=>
string(1) "1"
}
["categories_id"]=>
string(2) "12"
["authors_id"]=>
string(2) "16"
["brands_id"]=>
string(2) "36"
["models_id"]=>
string(3) "206"
["engines_id"]=>
string(3) "174"
["o-categories"]=>
array(1) {
["values"]=>
array(1) {
[12]=>
array(15) {
["categories_id"]=>
string(2) "12"
["object_id"]=>
string(1) "1"
["parent_id"]=>
string(1) "0"
["path"]=>
string(2) "12"
["handler"]=>
string(0) ""
["icon"]=>
string(0) ""
["tpl"]=>
string(12) "articles.php"
["alias"]=>
string(1) "0"
["is_nav"]=>
string(1) "1"
["pos"]=>
string(2) "10"
["depth"]=>
string(1) "0"
["cts"]=>
string(0) ""
["mts"]=>
string(0) ""
["configuration"]=>
string(0) ""
["el"]=>
array(15) {
["categories_id"]=>
string(2) "12"
["lang"]=>
string(2) "el"
["category_name"]=>
string(13) "Classic"
["sub_title"]=>
string(0) ""
["summary"]=>
string(0) ""
["image"]=>
string(0) ""
["html_code"]=>
string(0) ""
["meta_title"]=>
string(0) ""
["url"]=>
string(13) "classic"
["url_path"]=>
string(13) "classic"
["meta_keywords"]=>
string(0) ""
["meta_description"]=>
string(0) ""
["created"]=>
string(10) "1355235888"
["last_updated"]=>
string(1) "0"
["status"]=>
string(1) "1"
}
}
}
}
["o-authors"]=>
array(1) {
["values"]=>
array(1) {
[16]=>
array(4) {
["authors_id"]=>
string(2) "16"
["object_id"]=>
string(2) "26"
["image"]=>
string(0) ""
["el"]=>
array(9) {
["authors_id"]=>
string(2) "16"
["lang"]=>
string(2) "el"
["name"]=>
string(31) "Last First"
["last_name"]=>
string(10) "Last"
["first_name"]=>
string(20) "First"
["nick_name"]=>
string(0) ""
["created"]=>
string(10) "1360567827"
["last_updated"]=>
string(1) "0"
["status"]=>
string(1) "1"
}
}
}
}
["o-brands"]=>
array(1) {
["values"]=>
array(1) {
[36]=>
array(6) {
["brands_id"]=>
string(2) "36"
["object_id"]=>
string(2) "17"
["brand_name"]=>
string(11) "AUTOBIANCHI"
["created"]=>
string(10) "1363179463"
["last_updated"]=>
string(1) "0"
["status"]=>
string(1) "1"
}
}
}
["o-models"]=>
array(1) {
["values"]=>
array(1) {
[206]=>
array(7) {
["models_id"]=>
string(3) "206"
["object_id"]=>
string(2) "18"
["brands_id"]=>
string(2) "36"
["model_name"]=>
string(11) "A112 ABARTH"
["created"]=>
string(10) "1363179480"
["last_updated"]=>
string(1) "0"
["status"]=>
string(1) "1"
}
}
}
["o-engines"]=>
array(1) {
["values"]=>
array(1) {
[174]=>
array(6) {
["engines_id"]=>
string(3) "174"
["object_id"]=>
string(2) "19"
["engine"]=>
string(5) "1.050"
["created"]=>
string(10) "1363179448"
["last_updated"]=>
string(1) "0"
["status"]=>
string(1) "1"
}
}
}
}
}
Can you try
$article=getArticle($id);
if (is_array($article)) {
$article = reset($article);
}
or
$article=getArticle($id);
if (is_array($article)) {
$article = array_shift($article);
}
You can look into the documentation about reset and the documentation about array_shift.
If you copy array in getArticle() function then its internal pointer is lost.
I think this is the reason, it returns false.
If this is the vam dump of Request (var_dump($_REQUEST);):
array(1) {
["gift_edit"]=>
array(11) {
["name"]=>
string(19) "IBM da colezionista"
["description"]=>
string(0) ""
["validbegin"]=>
array(3) {
["day"]=>
string(2) "31"
["month"]=>
string(1) "1"
["year"]=>
string(4) "2013"
}
["validend"]=>
array(3) {
["day"]=>
string(1) "3"
["month"]=>
string(1) "3"
["year"]=>
string(4) "2015"
}
["redemption"]=>
string(13) "1234567888844"
["points"]=>
string(4) "1200"
["price"]=>
string(4) "6000"
["discount"]=>
string(2) "20"
["codelist"]=>
string(33) "unoperibm
dueperibm
treperibm
"
["amount"]=>
string(0) ""
["_token"]=>
string(40) "f2389c3d302630a624c10660aac218d279953d06"
}
}
How do you retrieve codelist?
$_REQUEST['gift_edit']['codelist'] or $_POST['gift_edit']['codelist'].
You could access it with the following code.
$_REQUEST['gift_edit']['codelist']
Try:
$test = $_REQUEST['gift_edit']['codelist'];
I am starting with the answer on this page PHP/mySQL - how to fetch nested rows into multidimensinal array because I am working with the same kind of relationship between tables. My code now looks like this:
$query=sprintf("SELECT * FROM product INNER JOIN production ON product.ID = production.product_ID");
$data = mysql_query($query);
$products = array();
while ($row = mysql_fetch_assoc($data))
{
if (!isset($products[$row['product_ID']]))
{
$row['production'] = array();
$products[$row['product_ID']] = $row;
}
$products[$row['product_ID']]['production'][] = $row;
}
foreach ($products as $product)
{
foreach ($product['production'] as $item)
//... do stuff
}
The query is solid - I have tried this directly on the database.
My problem is that I can't work out the final bit where it says //... do stuff
No matter what combination of variables etc I stick in there I get ArrayArrayArray (etc). What I want is to get a table of output which I can work with.
I hope this is enough information, this is my first question on StackOverflow. Thank you.
When I do var_dump($item) I get a long display which looks like this:
array(9) { ["ID"]=> string(1) "2" ["product_name"]=> string(10) "Drums 12kg" ["order"]=> string(2) "20" ["hidden"]=> string(1) "0" ["id"]=> string(1) "4" ["product_ID"]=> string(1) "2" ["date"]=> string(10) "2012-09-07" ["quantity"]=> string(3) "130" ["production"]=> array(0) { } } array(8) { ["ID"]=> string(1) "2" ["product_name"]=> string(10) "Drums 12kg" ["order"]=> string(2) "20" ["hidden"]=> string(1) "0" ["id"]=> string(2) "21" ["product_ID"]=> string(1) "2" ["date"]=> string(10) "2012-07-13" ["quantity"]=> string(3) "705" } array(8) { ["ID"]=> string(1) "2" ["product_name"]=> string(10) "Drums 12kg" ["order"]=> string(2) "20" ["hidden"]=> string(1) "0" ["id"]=> string(2) "23" ["product_ID"]=> string(1) "2" ["date"]=> string(10) "2012-07-13" ["quantity"]=> string(2) "23" } array(8) { ["ID"]=> string(1) "2" ["product_name"]=> string(10) "Drums 12kg" ["order"]=> string(2) "20" ["hidden"]=> string(1) "0" ["id"]=> string(2) "26" ["product_ID"]=> string(1) "2" ["date"]=> string(10) "2012-07-13" ["quantity"]=> string(2) "23" } array(8) { ["ID"]=> string(1) "2" ["product_name"]=> string(10) "Drums 12kg" ["order"]=> string(2) "20" ["hidden"]=> string(1) "0" ["id"]=> string(2) "28" ["product_ID"]=> string(1) "2" ["date"]=> string(10) "2012-07-19" ["quantity"]=> string(2) "12" } array(9) { ["ID"]=> string(1) "3" ["product_name"]=> string(12) "Nibbles 12kg" ["order"]=> string(2) "65" ["hidden"]=> string(1) "0" ["id"]=> string(1) "5" ["product_ID"]=> string(1) "3" ["date"]=> string(10) "2012-09-07" ["quantity"]=> string(2) "10" ["production"]=> array(0) { } } array(8) { ["ID"]=> string(1) "3" ["product_name"]=> string(12) "Nibbles 12kg" ["order"]=> string(2) "65" ["hidden"]=> string(1) "0" ["id"]=> string(2) "10" ["product_ID"]=> string(1) "3" ["date"]=> string(10) "2012-09-07" ["quantity"]=> string(2) "10" } array(8) { ["ID"]=> string(1) "3" ["product_name"]=> string(12) "Nibbles 12kg" ["order"]=> string(2) "65" ["hidden"]=> string(1) "0" ["id"]=> string(2) "14" ["product_ID"]=> string(1) "3" ["date"]=> string(10) "2012-07-12" ["quantity"]=> string(3) "140" } array(8) { ["ID"]=> string(1) "3" ["product_name"]=> string(12) "Nibbles 12kg" ["order"]=> string(2) "65" ["hidden"]=> string(1) "0" ["id"]=> string(2) "16" ["product_ID"]=> string(1) "3" ["date"]=> string(10) "2012-07-12" ["quantity"]=> string(3) "220" } array(8) { ["ID"]=> string(1) "3" ["product_name"]=> string(12) "Nibbles 12kg" ["order"]=> string(2) "65" ["hidden"]=> string(1) "0" ["id"]=> string(2) "17" ["product_ID"]=> string(1) "3" ["date"]=> string(10) "2012-07-04" ["quantity"]=> string(3) "120" } array(9) { ["ID"]=> string(1) "4" ["product_name"]=> string(16) "Breast meat 12kg" ["order"]=> string(2) "40" ["hidden"]=> string(1) "0" ["id"]=> string(1) "6" ["product_ID"]=> string(1) "4" ["date"]=> string(10) "2012-09-07" ["quantity"]=> string(2) "20" ["production"]=> array(0) { } } array(8) { ["ID"]=> string(1) "4" ["product_name"]=> string(16) "Breast meat 12kg" ["order"]=> string(2) "40" ["hidden"]=> string(1) "0" ["id"]=> string(2) "11" ["product_ID"]=> string(1) "4" ["date"]=> string(10) "2012-09-07" ["quantity"]=> string(2) "20" } array(8) { ["ID"]=> string(1) "4" ["product_name"]=> string(16) "Breast meat 12kg" ["order"]=> string(2) "40" ["hidden"]=> string(1) "0" ["id"]=> string(2) "13" ["product_ID"]=> string(1) "4" ["date"]=> string(10) "2012-10-10" ["quantity"]=> string(2) "75" } array(9) { ["ID"]=> string(1) "5" ["product_name"]=> string(11) "Value Birds" ["order"]=> string(2) "50" ["hidden"]=> string(1) "0" ["id"]=> string(1) "7" ["product_ID"]=> string(1) "5" ["date"]=> string(10) "2012-09-07" ["quantity"]=> string(2) "40" ["production"]=> array(0) { } } array(8) { ["ID"]=> string(1) "5" ["product_name"]=> string(11) "Value Birds" ["order"]=> string(2) "50" ["hidden"]=> string(1) "0" ["id"]=> string(2) "12" ["product_ID"]=> string(1) "5" ["date"]=> string(10) "2012-09-07" ["quantity"]=> string(2) "40" } array(9) { ["ID"]=> string(1) "1" ["product_name"]=> string(11) "Thighs 12kg" ["order"]=> string(3) "105" ["hidden"]=> string(1) "1" ["id"]=> string(1) "8" ["product_ID"]=> string(1) "1" ["date"]=> string(10) "2012-10-01" ["quantity"]=> string(3) "500" ["production"]=> array(0) { } } array(9) { ["ID"]=> string(1) "7" ["product_name"]=> string(19) "Whole birds size 13" ["order"]=> string(2) "70" ["hidden"]=> string(1) "1" ["id"]=> string(2) "29" ["product_ID"]=> string(1) "7" ["date"]=> string(10) "2012-07-13" ["quantity"]=> string(3) "500" ["production"]=> array(0) { } } array(8) { ["ID"]=> string(1) "7" ["product_name"]=> string(19) "Whole birds size 13" ["order"]=> string(2) "70" ["hidden"]=> string(1) "1" ["id"]=> string(2) "30" ["product_ID"]=> string(1) "7" ["date"]=> string(10) "2012-07-13" ["quantity"]=> string(3) "500" } array(8) { ["ID"]=> string(1) "7" ["product_name"]=> string(19) "Whole birds size 13" ["order"]=> string(2) "70" ["hidden"]=> string(1) "1" ["id"]=> string(2) "31" ["product_ID"]=> string(1) "7" ["date"]=> string(10) "2012-07-19" ["quantity"]=> string(3) "500" } array(8) { ["ID"]=> string(1) "7" ["product_name"]=> string(19) "Whole birds size 13" ["order"]=> string(2) "70" ["hidden"]=> string(1) "1" ["id"]=> string(2) "32" ["product_ID"]=> string(1) "7" ["date"]=> string(10) "2012-07-13" ["quantity"]=> string(3) "500" }
You are going to construct your table's html inside your last two foreach loops. I would recommend naming your columns better as the text that identifies your array keys in item is confusing (you have three ID fields).
print "<table><thead><tr><th>ID</th><th>Product</th><th>Order</th><th>Hidden</th><th>ID</th><th>Product ID</th><th>date</th><th>Quantity</th></tr></thead><tbody>";
foreach ($products as $product)
{
foreach ($product['production'] as $item)
{
print "<tr>";
print "<td>$item['ID']</td>";
print "<td>$item['product_name']</td>";
print "<td>$item['order']</td>";
print "<td>$item['hidden']</td>";
print "<td>$item['id']</td>";
print "<td>$item['product_id']</td>";
print "<td>$item['date']</td>";
print "<td>$item['quantity']</td>";
print "</tr>";
}
}
print "</tbody></table>";