Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Help with PHP / MySQL
Old 10-05-2007, 06:15 AM Help with PHP / MySQL
nickharper's Avatar
Extreme Talker

Latest Blog Post:
Testing this bad boy out!!!!!
Posts: 221
Name: Nick
Location: Coventry, UK
Trades: 1
Right,

I have 4 fields in a row

Ingred1
Ingred2
Ingred3
Ingred4

These could be for ingredients for food, let's say flour, egg, butter and milk.

When somebody submits a recipe it may look something like this:

Ingred 1 = Butter
Ingred 2 = Milk
Ingred 3 = Egg
Ingred 4 = Flour

This is all well and good, but if somebody submits a recipe like this:

Ingred 1 = Butter
Ingred 2 = Egg
Ingred 3 = Milk
Ingred 4 = Flour

It now means that Egg is in both fields Ingred 3 and 2.

I want to run a list of all the ingredients of my site off.

I could use DISTINCT but this would only show me distinct for ingred1 and not overall between the 4 different ingred field.

I would want it to just list the ingredients without repeating like:

Butter
Egg
Flour
Milk

How would I go about this?

Thanks
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE

nickharper is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 10-05-2007, 06:46 AM Re: Help with PHP / MySQL
Experienced Talker

Posts: 44
Name: Kuldeep Sahi
Trades: 0
You have to normalise and redesign your data into 3 tables:

1) Recipe (RecipeID, RecipeName)
2) Ingredients (IngredientID, IngredientName, IngredientMeasure, etc)
3) Recipe-Ingredients. (RecipeID, IngredientID, IngredientQuantity)

You can then run your query easily.
__________________

Please login or register to view this content. Registration is FREE
,
Please login or register to view this content. Registration is FREE
,
Please login or register to view this content. Registration is FREE
Kuldeep2195 is offline
Reply With Quote
View Public Profile Visit Kuldeep2195's homepage!
 
Old 10-05-2007, 06:48 AM Re: Help with PHP / MySQL
nickharper's Avatar
Extreme Talker

Latest Blog Post:
Testing this bad boy out!!!!!
Posts: 221
Name: Nick
Location: Coventry, UK
Trades: 1
How do I go about merging the 2 together into the 3rd table?
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE

nickharper is offline
Reply With Quote
View Public Profile
 
Old 10-06-2007, 11:06 AM Re: Help with PHP / MySQL
Novice Talker

Posts: 14
Name: kiran
Trades: 0
Check out the tutorials on arrays from php.net that can be a real help when you do php,
__________________
for
Please login or register to view this content. Registration is FREE
and
Please login or register to view this content. Registration is FREE
webdesignseo.co.uk
Please login or register to view this content. Registration is FREE
kiranshotgun is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Help with PHP / MySQL
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.29464 seconds with 12 queries