Jump to content

Explode Question


wemustdesign

Recommended Posts

Hi,

 

I have a database that is going to contain recepies and ingredients tables. The recipe table is going to store the ingredients like this:

 

1,5,6,8

 

This refers to the table ingredients id.

 

I now want to explode these vaules and count them up so they can be outputted like this:

 

sugar (2)

honey(1)

flour (3)

 

I have no idea of how to count all of the exploded id's and ouput them like above

Link to comment
https://forums.phpfreaks.com/topic/218709-explode-question/
Share on other sites

I think u should give thought about the design of the db before making a db that becomes inflexible later on.

there is no need to store all the recipes ingredients in the same table, if u design your db for flexibility in for the long run.

as most of what your asking SQL can already handle

 

 

 

Recipe Table:

id

Name

Description

Instructions

 

Ingredients

id

Name

 

RecipeIngredients

RecipeId

IngredientID

Amount

 

with those 3 tables, I can do exactly wut u need all within sql

 

Link to comment
https://forums.phpfreaks.com/topic/218709-explode-question/#findComment-1134338
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.