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
https://forums.phpfreaks.com/topic/99884-inserting-data-into-a-db/
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..

Archived

This topic is now archived and is closed to further replies.

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