Jump to content

How do I use a variable with return result from dropdown with MySql lookup?


rmiddleton

Recommended Posts

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]

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.