Jessica
Staff Alumni-
Posts
8,968 -
Joined
-
Last visited
-
Days Won
41
Everything posted by Jessica
-
This code works. <script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script> <input type="checkbox" name="master_plan" value="Master Plan" /> <script type="text/javascript"> $(document).ready(function(){ $('input[name=master_plan]').click( function(){ alert($(this).val()); } ); }); </script> Figure out what's different in yours.
-
I don't get why you'd take the time to write something completely different than your actual code, to post it here. Do you see the difference between the names on the inputs in this and your original post? For the record, your Label should be before or after your checkbox, not surrounding it.
-
Show me your "real" html. Probably the first one. I don't know. What does it say if you alert() it?
-
Don't put an empty variable in your SQL. If you echo the entire SQL string you would see where it's wrong.
-
Well. Did you READ the error?
-
Your HTML doesn't have an input with the name of master_plan.
-
How did you get every OTHER form element's value? Did you try looking it up in the jQuery manual? It explicitly tells you how to do this. http://api.jquery.com/val/
-
Did you get a mysql error? Did you echo the query and run it in mysql? What makes you think it's not working? PS: MySQL uses AND.
-
There's nothing in your script that even attempts to do what you're asking. So... Try it and see.
-
This is the pot calling the kettle black if I ever saw it.
-
When you say the new rows don't display information that doesn't make sense. Rows are stored info. Either you're using PHP or the mysql interface to view them. WHAT is it that makes you think there is a problem??
-
I have no idea what you mean but if you understood me then we're good
-
1. A recipe produces a new ingredient. Combine a and b to make c. 2. That was a mistake, thank you! Fixed.
-
If the data shows up in PHPMyAdmin, then the problem is the PHP code that displays the data on your webpage. We can't help without seeing the data and the code.
-
Oh fuck me. I thought I tried this, but after double checking the comments in the manual say you can use DISTINCT inside the GROUP_CONCAT. SELECT recipes.recipe_id, GROUP_CONCAT(DISTINCT recipe_ingredients.ingredient_id ORDER BY recipe_ingredients.ingredient_id ASC) AS ingredient_ids, GROUP_CONCAT(DISTINCT recipe_ingredients.quantity ORDER BY recipe_ingredients.ingredient_id ASC) AS quantities, GROUP_CONCAT(DISTINCT recipe_settings.appliance_setting_id ORDER BY recipe_settings.appliance_setting_id ASC) AS appliance_settings, GROUP_CONCAT(DISTINCT recipe_settings.appliance_setting_option_id ORDER BY recipe_settings.appliance_setting_option_id ASC) AS appliance_options, recipes.ingredient_id FROM recipes etc.... Works. *headdesk*
-
OK so it worked with the first child table, but now that I have added a second type of child table, it's not working as I expected. This is really complicated. I am trying to find recipe id #3 based on matching it's one recipe_ingredient and two recipe_settings. Table Structures: CREATE TABLE IF NOT EXISTS `recipes` ( `recipe_id` int(10) unsigned NOT NULL AUTO_INCREMENT, `ingredient_id` varchar(100) NOT NULL, `appliance_id` int(10) unsigned NOT NULL, PRIMARY KEY (`recipe_id`), KEY `appliance_id` (`appliance_id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=4 ; INSERT INTO `recipes` (`recipe_id`, `ingredient_id`, `appliance_id`) VALUES (1, '5', 1), (2, '6', 1), (3, '7', 2); -- this one CREATE TABLE IF NOT EXISTS `recipe_ingredients` ( `recipe_id` int(10) unsigned NOT NULL, `ingredient_id` int(10) unsigned NOT NULL, `quantity` int(10) unsigned NOT NULL, PRIMARY KEY (`recipe_id`,`ingredient_id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; INSERT INTO `recipe_ingredients` (`recipe_id`, `ingredient_id`, `quantity`) VALUES (1, 1, 2), (1, 3, 2), (2, 2, 2), (2, 3, 1), (3, 5, 1); -- this one CREATE TABLE IF NOT EXISTS `recipe_settings` ( `recipe_id` int(10) unsigned NOT NULL, `appliance_setting_id` int(10) unsigned NOT NULL, `appliance_setting_option_id` int(10) unsigned NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; INSERT INTO `recipe_settings` (`recipe_id`, `appliance_setting_id`, `appliance_setting_option_id`) VALUES (3, 2, 3), -- this one (3, 3, 5); -- this one The query I generate in PHP, which returns no results SELECT recipes.recipe_id, GROUP_CONCAT(recipe_ingredients.ingredient_id ORDER BY recipe_ingredients.ingredient_id ASC) AS ingredient_ids, GROUP_CONCAT(recipe_ingredients.quantity ORDER BY recipe_ingredients.ingredient_id ASC) AS quantities, GROUP_CONCAT(recipe_settings.appliance_setting_id ORDER BY recipe_settings.appliance_setting_id ASC) AS appliance_settings, GROUP_CONCAT(recipe_settings.appliance_setting_option_id ORDER BY recipe_settings.appliance_setting_option_id ASC) AS appliance_options, recipes.ingredient_id FROM recipes INNER JOIN recipe_ingredients ON recipe_ingredients.recipe_id = recipes.recipe_id INNER JOIN recipe_settings ON recipe_settings.recipe_id = recipes.recipe_id INNER JOIN ingredients ON ingredients.ingredient_id = recipes.ingredient_id WHERE appliance_id = 2 GROUP BY recipes.recipe_id HAVING ingredient_ids = '5' AND quantities = '1' AND appliance_settings = '2,3' AND appliance_options = '3,5' If I run the query without the HAVING clauses I get a row, but it has '5,5' and '1,1' where I expected just 5 and 1. The 2,3 and 3,5 parts are correct. recipe_id 3 ingredient_ids 5,5 quantities 1,1 appliance_settings 2,3 appliance_options 3,5 ingredient_id 7 I suspect this is because there are two children in recipe_settings and only one in recipe_ingredients for recipe #3. So how do I get it to only count/group_concat the 5 and 1 one time each? SELECT * FROM recipes INNER JOIN recipe_ingredients ON recipe_ingredients.recipe_id = recipes.recipe_id INNER JOIN recipe_settings ON recipe_settings.recipe_id = recipes.recipe_id INNER JOIN ingredients ON ingredients.ingredient_id = recipes.ingredient_id WHERE appliance_id =2 recipe_id 3 3 ingredient_id 7 7 appliance_id 2 2 ingredient_id 5 5 quantity 1 1 appliance_setting_id 2 3 appliance_setting_option_id 3 5 ingredient_id 7 7
-
That's a serialized object, not an array.
-
You need to read some basic PHP tutorials.
-
SQL = server query language MySQL = a specific database that uses a specific dialect of SQL. Mysqli = the improved mysql interface for PHP. You are using SQL no matter what. If you want to use mysqli functions you have to change all of your mysql_ functions to mysql_, and the manual documents the functions. But if you were doing that you might as well switch to PDO. You don't need to switch in order to get your column names. You should switch if this is new code you're writing now.
-
Good job answering the important questions. Good luck.
-
Damn forum software. Can we switch back yet?
-
Dude I'm drunk right now and I can see what's wrong with your code. And I explained it. You definitely need to simplify the code but the fact that you're using $_POST wrong is why your mail fails.
-
Is your email address "someone@drpgraphicdesign.com" or is it stored in the post array at the index "someone@drpgraphicdesign.com"??? Did you post a field named "someone@drpgraphicdesign.com"????
-
Do you understand how PHP variables work? Arrays? The superglobal POST?
-
Oh. My. God. Really. I think you got a little over zealous with the post array. I doubt you actually posted those last few.