I have a table with inventory stuff in it and would like to know how to display the results. I'll use a simple example to ask my question about displaying resluts from a query.
I have table called beverages. The primary field is the user name. All the other fields are int(11), not null, and default 0. The purpose of the fields is to display how many of each item the person owns. The field names are user_name, Pepsi, Coke, and Sprite. Under the record "Don" it has vales of 2, 1, and 3 respectively. What I can do using a query and fetch_array, then a foreach, I can print the values out one each in a new table row. So the results are:
2
1
3
What I want to do is display the filed name also, so it looks like:
Pepsi 2
Coke 1
Sprite 3
Also, if there is a way to have it not return a result if the entry is 0, so that if there 0 Sprite, it would only display Pepsi and Coke. The reason I don't create a table with the filed names hardcoded in already is (1)the 0 fields won't be displayed and (2) there are several hundred fields in the inventory database I am using and I would like to be able to add more at any given time without having to hardcode hem into a table also at the same time.
I hope this makes sense, if you can help, I would really appreciate it, feel free to e-mail if I don't make something clear here and you want to furthur describe my prob.
Thanks