Jump to content

inserting <select> data into a DB


unsider

Recommended Posts

Suprisingly this is the first time I'm working with <select> tags, and the data just so happens to be 'gender'. With the option of selecting 2 values. "Male", "Female".

 

Well I need to take this information and write it to my database.

 

There is already a connection to my database, and everything is functional, I'm just not sure how I'm not sure of the syntax.

 

DB = mtlc?old

table = 'users'

feild = 'gender'

 

This is all strictly input, I will be outputting the data elsewhere.

 


<table>
<tr>
<td>Gender:</td>
<td><select class="select" name="gender" id="gender" value="
<?php
if($form->value("gender") == ""){
   echo $session->userinfo['gender'];
}else{
   echo $form->value("gender");
}
?>"> 

<option value="-1">Gender:</option>
<option value="1">Female</option>
<option value="2">Male</option>
</select>
</td></tr>


<tr>
<td>Gender:</td>
<td><input type="text" name="gender" value="

</td>
<td><?php echo $form->error("gender"); ?></td>
</tr>
</table>

 

Thanks, if anyone can help.

 

Link to comment
Share on other sites

Well first of all there are two things I see with your code that I dont think are right (though i'm not positive...)

 

First.. I've never seen the select tag have an actual "value" to it... Only the option tags..

 

Second of all...

<td><input type="text" name="gender" value="

</td>

 

One - it's not closed out.. Two... The textarea AND the select both have the same name? Never seen that either..

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.