Say i have a series of items , so items have multiple people associated with them

Item_id type_id person_id
1 1 1,2
2 1 3,4
3 2 1,3


Will this work when i search for them in php
say display
people with item one
person 1 and person 2

Recommended Answers

All 8 Replies

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.

I may have explained this badly
Say a restaurant has courses and meals but some courses contain the same meal

meal_id , meal_desc , course_id

course_id , course_desc

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?

Im trying to create an adobe filter system where people can find what software is right for them.

Say Dreamweaver

Software_id Software_name software_type
1 dreamweaver design,web
2 photoshop design
3 flash design,web

would i be able to search this table with php? so say find all software that is design or web or design and web.

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?

commented: id say same +4

ah so two thing can have the same id?

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.

select person_id from table where item_id = '1' ;

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.