How do i fetch multidimensional array data in my table. As per in my image foodname, quantity, price should be fetch in my table.
Asked
Active
Viewed 79 times
0
-
1HTML or MySQL table? I don't understand the question. – StackSlave Oct 16 '17 at 23:28
-
Firstly you need to tell us about the table is it a `HTML` table or a table in a data base. Then you need to add your code in code tags not as an image because no one will be able to copy paste and give it try. – S4NDM4N Oct 17 '17 at 03:44
-
This is post array comes from add to cart page to send email page. – J P Senthil Kumar Oct 17 '17 at 04:40
1 Answers
0
Let's assuming that you have the relationships set up in here.
Basically you would have on the food table: quatity_id
and price_id
.
Having the relationships we just need to do a join
:
select * from `food_table` where `food` = `Super man's soupe` join `quantity_table` where `food_table.quantity_id` = `food_table.id` join `price` where `food_table.price_id` = `food_table.id`
A join
assumes that you have all the data otherwise it will throw you an error. Let's suppose you have another food called Batman's soup
but you wouldn't have the price because you know... Batman has a shit ton of money. You would receive an error because you were trying to join
a column that does not exists. For cases like this we need to use leftjoin
.

Bruno Francisco
- 3,841
- 4
- 31
- 61
-
This table not fetched from mysql. This is just post array data from add to cart page to email send page. I just want to loop this array into my table. – J P Senthil Kumar Oct 17 '17 at 04:43
-
@JPSenthilKumar You should add a little bit of code and be more specific. Have you tried anything? – Bruno Francisco Oct 17 '17 at 12:36