We're a community of 1077K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,076,280 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

Mutiple Value Column

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

4
Contributors
8
Replies
1 Week
Discussion Span
1 Year Ago
Last Updated
9
Views
whit89
Light Poster
48 posts since Dec 2011
Reputation Points: 10
Solved Threads: 1
Skill Endorsements: 0

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

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

whit89
Light Poster
48 posts since Dec 2011
Reputation Points: 10
Solved Threads: 1
Skill Endorsements: 0

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

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.

whit89
Light Poster
48 posts since Dec 2011
Reputation Points: 10
Solved Threads: 1
Skill Endorsements: 0

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

ah so two thing can have the same id?

whit89
Light Poster
48 posts since Dec 2011
Reputation Points: 10
Solved Threads: 1
Skill Endorsements: 0

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

select person_id from table where item_id = '1' ;

rajeevphp2011
Light Poster
26 posts since Nov 2011
Reputation Points: 7
Solved Threads: 6
Skill Endorsements: 1

This article has been dead for over three months: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
 
© 2013 DaniWeb® LLC
Page rendered in 0.0961 seconds using 2.7MB