fludorf Posted October 17, 2010 Share Posted October 17, 2010 Hi all, I am pretty new to the whole php/mysql topic. I am trying to create my own recipe db and I have run into an issue which I cant seem to get around. I am hoping someone can give me to pointers. Basically I would like to display a page which contains recipe details (name, difficulty etc plus the ingredients and procedure). I the information to display this for a particular recipe is spread over 5 tables: 1. tbl_recipes (high level information about the recipes (name, difficulty, etc) 2. tbl_ingredients (list if all available recipes (id, ingredient name) 3. tbl_x_ingredients (intersection table where I have recipe ID and ingredient ID) 4,5 same idea as 2 and 3 but just for procedure. My first approach was to fire off an sql statement querying the tbl_recipes table and displaying the info on one section of the page. This was ok. The I thought I would simply send a second query displaying all the ingredients for the recipe in a second part or of the page. I ran into issue with this and though using mqsli->multi_query was the solution but also failed to get that working Then I thought I just needed to create a sql statement which has all the results included. However there I got stuck with how to display the data properly. I would get recipe id, name, ingredient 1, pasta, noodles 1, pasta, salt 1, pasta, pepper The problem with this is that I would not know how to parse this result set to display as described above, Any ideas? I would be very grateful of any suggestions. Quote Link to comment https://forums.phpfreaks.com/topic/216075-help-with-displaying-data-from-mysql/ Share on other sites More sharing options...
fenway Posted October 17, 2010 Share Posted October 17, 2010 Sorry, I don't follow. Quote Link to comment https://forums.phpfreaks.com/topic/216075-help-with-displaying-data-from-mysql/#findComment-1122988 Share on other sites More sharing options...
fludorf Posted October 17, 2010 Author Share Posted October 17, 2010 Hi, what part of it do you not follow? I am trying display data which comes back in to form: recipe id | name | ingredient ---------------------------------- 1 | pasta | noodles 1 | pasta | salt 1 | pasta | pepper I would like to display in php: Recipe Name: Pasta Ingredients: Noodles Pepper Salt I can do the above part easily with something like while($row = mysqli_fetch_assoc($result)) { $title=$row['Title']; $difficulty=$row['Difficulty']; $time=$row['Time']; Its the lower part that I am lost with. Does this help`? Quote Link to comment https://forums.phpfreaks.com/topic/216075-help-with-displaying-data-from-mysql/#findComment-1123017 Share on other sites More sharing options...
fenway Posted October 17, 2010 Share Posted October 17, 2010 Not really -- you obviously have the ingredient list already -- so what's the problem? Quote Link to comment https://forums.phpfreaks.com/topic/216075-help-with-displaying-data-from-mysql/#findComment-1123045 Share on other sites More sharing options...
fludorf Posted October 17, 2010 Author Share Posted October 17, 2010 thank you Quote Link to comment https://forums.phpfreaks.com/topic/216075-help-with-displaying-data-from-mysql/#findComment-1123068 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.