473,405 Members | 2,310 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

php & mysql puzzle

1
Hi there,
I'm new to php & mysql and would really appreciate some help with the following:

I'd like to display a list of products and a string showing the categories they fall into:
- a product can be in 0 - 5 categories
- the products table holds five columns for each potential category
- each category column can hold a code (foriegn key)
- the category code is the primary key in the category table
- the category table has a column for the category name (e.g., 'dark', 'milk', 'white', 'fruit', 'nuts')

I would like to display:
ChoccySelect - dark, fruit, nuts
ChunkChocbar - milk, nuts
ChoccyChoccyDeelite - dark, milk, white, fruit

but have only managed
ChoccySelect - 01, 04, 05
ChunkChocbar - 02, 05
ChoccyChoccyDeelite - 01, 02, 03, 04


my code is:
$tresults = @mysql_query('SELECT g.product_name, g.cat_1, g.cat_2, g.cat_3, g.cat_4, g.cat_5, t.cat_code, t.cat_desc FROM products g LEFT JOIN cat_lookup t ON t.cat_code IN (g.cat_1, cat_2, cat_3, cat_3, cat_4, cat_5) ORDER BY product_name');


while ($tresult = mysql_fetch_array($tresults)) {
$tcode = $tresult['cat_code'];
$gname = $tresult[‘product_name'];
$cata = $tresult['cat_1'];
$catb = $tresult['cat_2'];
$catc = $tresult['cat_3'];
$catd = $tresult['cat_4'];
$cate = $tresult['cat_5'];


echo "<tr><td>$gname &nbsp; ($cata, $catb, $catc, $catd, $cate)</td></tr>\n";

(I wasn't kidding when I said I was new to this!)

Thanks,
L.
Mar 14 '07 #1
1 1204
ak1dnar
1,584 Expert 1GB
please re-submit this post with the complete PHP script, and MySQL DB script.
What ever the thing in your original post is too complex to understand.
and please wrap the codings with the relevant tags.
Mar 16 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

23
by: ian justice | last post by:
Before i post actual code, as i need a speedyish reply. Can i first ask if anyone knows off the top of their head, if there is a likely obvious cause to the following problem. For the moment i've...
5
by: Raju V.K | last post by:
I am developing a web site which requires a set og unique values be transferred between pages and server many times. There fore i decided to put the values in an array so that only one reference to...
0
by: Jamie Krasnoo | last post by:
Will placing Apache::RequestRec & Apache::RequestIO & APR::Table in startup.pl to load them up for multiple handlers have any bad side effects? I noticed that when I load them via startup.pl the...
4
by: MLH | last post by:
A programmer developed an AMP (Apache/MySQL/PHP) application for me. When he was done, he sent me the PHP files and the MySQL dump file. Now, when I connect to the application on my LAN using...
1
by: xavier vazquez | last post by:
I have a problem with a program that does not working properly...when the program run is suppose to generate a cross word puzzle , when the outcome show the letter of the words overlap one intop of...
0
by: xavier vazquez | last post by:
have a problem with a program that does not working properly...when the program run is suppose to generate a cross word puzzle , when the outcome show the letter of the words overlap one intop of the...
10
by: rup | last post by:
Hello, This is my first application on socket programming in vc++. I am facing problem that how to make connection to server, & make GET/POST request by HTTP. Please help me. Its urgent.......
2
by: Gio | last post by:
I'm getting K&R (it's on the way), should I also get the Answer Book? And while I'm there, should I get the Puzzle Book? Or should I save the Puzzle Book for when I'm more advanced? - Gio ...
4
by: honey777 | last post by:
Problem: 15 Puzzle This is a common puzzle with a 4x4 playing space with 15 tiles, numbered 1 through 15. One "spot" is always left blank. Here is an example of the puzzle: The goal is to...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.