rmiddleton Posted February 9, 2011 Share Posted February 9, 2011 I have found postings close, but not close enough to find my error. I am looking up data from a MySql table and putting it in a dropdown box on a form. I can select the item, but apparently not really. I am not able to echo it, or post it to a record. I'm sure I am missing something simple, but... Code attached if anyone can show me the errors of my ways. Thank you. [attachment deleted by admin] Quote Link to comment https://forums.phpfreaks.com/topic/227180-how-do-i-use-a-variable-with-return-result-from-dropdown-with-mysql-lookup/ Share on other sites More sharing options...
Psycho Posted February 9, 2011 Share Posted February 9, 2011 The code you provide shows a select field (called 'types') which is populated from the database. Since you are using the same value for the option value and the option text I will assume that the options do have values. You are then apparently POSTing the form (with the select list in question) to another page. But, you are apparenlty having a problem accessing the POSTed value on that page. Assuming you are getting directed to the correct processing page ($editFormAction) then the problem lies in that page. EDIT: By the way, you have some superfulous (sp?) code here $result = mysql_query($sql) or die ($sql . '<br />' . mysql_error); if (!$result) { echo 'Query failed'; exit; } If the query failes the "or die()" satatement will execute. So, the "if (!$result)" could never be run. Quote Link to comment https://forums.phpfreaks.com/topic/227180-how-do-i-use-a-variable-with-return-result-from-dropdown-with-mysql-lookup/#findComment-1171905 Share on other sites More sharing options...
rmiddleton Posted February 9, 2011 Author Share Posted February 9, 2011 The "Entry_Type" (required in MySql table) is null. I need to populate "Entry_Type" variable with the result from the dropdown </select>. Modifyed the code since I submitted it, but still haven't hit the correct process / syntax. Quote Link to comment https://forums.phpfreaks.com/topic/227180-how-do-i-use-a-variable-with-return-result-from-dropdown-with-mysql-lookup/#findComment-1171906 Share on other sites More sharing options...
rmiddleton Posted February 9, 2011 Author Share Posted February 9, 2011 Thank you on the "redundant code from the department of redundancy". Remored it. As to the problem, it never gets to another form, it should process the insert from this page, but apparently until I can make "Entry_Type" = <select> I can't get past that point. Quote Link to comment https://forums.phpfreaks.com/topic/227180-how-do-i-use-a-variable-with-return-result-from-dropdown-with-mysql-lookup/#findComment-1171918 Share on other sites More sharing options...
Psycho Posted February 9, 2011 Share Posted February 9, 2011 As to the problem, it never gets to another form, it should process the insert from this page, but apparently until I can make "Entry_Type" = <select> I can't get past that point. I'm not following your statements. On the code you attached, you are creating a form with a select field called "types" - there is a separate INPUT field called "Entry_Type" but since you did not specify a type property for that input I am assuming it is defaulting to a Text input. The form looks "OK". You are then POSTing that form to a processing page - is that processing page the same page? If so, there is nothing in the code that runs the query which does anything with $_POST['types'], which would be the value from that select list. The query does use $_POST['Entry_Types'] - but that is the misformatted input field not the select list. Are you referencing the wrong field? Quote Link to comment https://forums.phpfreaks.com/topic/227180-how-do-i-use-a-variable-with-return-result-from-dropdown-with-mysql-lookup/#findComment-1171939 Share on other sites More sharing options...
rmiddleton Posted February 10, 2011 Author Share Posted February 10, 2011 Thank you! I said I had to be overlooking something simple. "Forrest for the trees problem." Wrong name in select was exactly the problem. Thanks again! Quote Link to comment https://forums.phpfreaks.com/topic/227180-how-do-i-use-a-variable-with-return-result-from-dropdown-with-mysql-lookup/#findComment-1172239 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.