I've spent the last few days understanding and getting the correct code combinations to create a form to enter recipes into a database. I know there are "similar" questions and discussions about Concat syntax, but recipes is something I've never found to go from start to finish, including the html.
Here is where I found the data for creating the database and then (attempting) to use the below code (from guignol - that was the most complete and most recent code I could find): SO recipe database
I've added several columns to the "recipe" table. I don't have a problem (now) entering data into the database using all the found code (although I did have to update and make minor changes to eliminate errors using the code "as-is").
I am using mysqli and php in case it makes any difference. If anybody has a better solution I'm happy to switch horses. I also know many people have various methods. But recipes is a hard nut to crack because of the relationships and variations for each entry. I'm hoping the great "recipe guru" will find this post and advise me well.
The "full" error here:
Parse error: syntax error, unexpected 'recipes' (T_STRING) in C:\wamp64\www\LocalHire\trials\mencook-recipes.php on line 57
Line 57 is the first LEFT JOIN syntax.
I'm still researching and have found the solution to the "first" error. So instead of getting booted "again" because the question is similar to other answers that are "NOT" answers to my question, if this one gets booted I'll just continue to research. Many answers are incomplete, especially for those not educated in CONCAT and LEfT JOIN. So when finding "an" answer, I usually try the code, get a lot of errors and try to resolve them 1-by-1. But in this case, I have no clue how to LEFT JOIN. I did finally get passed the CONCAT.
Here's what I have for selecting the data:
$sql = "SELECT recipes.id, recipes.name AS recipeName, ingredients.name AS ingredientNeeded, CONCAT(ingredients_recipes.Qty,' ',neededUnities.name) AS neededQuantity, CONCAT(inventories.qty,' ',inventoryUnities.name) AS availableQuantity FROM recipes"
LEFT JOIN ingredients_recipes ON recipes.id=ingredients_recipes.recipe_id
LEFT JOIN ingredients ON ingredients_recipes.ingredient_id = ingredients.id
LEFT JOIN inventories ON ingredients.id=inventories.ingredient_id
LEFT JOIN unities AS inventoryUnities ON inventories.unity_id=inventoryUnities.id
LEFT JOIN unities AS neededUnities ON ingredients_recipes.unity_id=neededUnities.id
WHERE inventories.`update` = (SELECT MAX(`update`) FROM inventories AS inv WHERE inv.ingredient_id = inventories.ingredient_id);