It is not a question of PHP. PHP can display anything which the database delivers.
Your database query is a very basic one. I suggest you take a mysql primer course before you ask more questions which you will know how to answer after the first lesson.
smantscheff
Nearly a Posting Virtuoso
1,297 posts since Oct 2010
Reputation Points: 321
Solved Threads: 270
Skill Endorsements: 8
Your second example is much better. You were trying to fit too much data into inappropriate columns in your first post.
Now if you wanted to find all courses that were part of a particular meal you can use SQL to extract the data form the database by joining the tables.
Do you have a real example of what you are trying to do and so code to show how far you've got so far?
hericles
Veteran Poster
1,065 posts since Nov 2007
Reputation Points: 156
Solved Threads: 228
Skill Endorsements: 9
No, you shouldn't hold two pieces of data in the same column. Having design and web in the same column matched against dreamweaver (for example) is incorrect.If you wanted to do this you would need at least 2 tables.
table 1: software
software_id
software_product
software_desc
table 2: software_uses
software_id
usage
So, in table 2 for dreamweaver you would have two rows (based on your example above and giving dreamweaver an id of 101).
software_uses
101 web
101 design
Now you can search for any software that matches a particular need and retrieve the name and description from table 1 using an SQL join.
Does that help?
hericles
Veteran Poster
1,065 posts since Nov 2007
Reputation Points: 156
Solved Threads: 228
Skill Endorsements: 9
Yes, as long as the column for the ID isn't defined as the sole primary key for the table. Tables like table 2 above are sometimes called linking tables as they form the relationship between two other tables. For example, you could have another table called uses and in that table name and describe the various things software could be used for (design, web, video editing, etc) and then table 2 forms the link between uses and software and would simply hold 2 columns - software_id and uses_id. Table 2 then allows all of the information in the tables to be joined in searches.
hericles
Veteran Poster
1,065 posts since Nov 2007
Reputation Points: 156
Solved Threads: 228
Skill Endorsements: 9