Hello Everyone!!
I have creted a dropdown having two option YES/No & in mysql db i have taken field type tinyint(1)
Here is the code:
HTML Page:
<td align=right>is_fertilised</td>
<td><select name= "is_fertilized" style="width: 120px;">
<option value="Yes">Yes</option>
<option value="No">No</option>
</select></td>
PHP code:
$sql1 = "INSERT INTO trees
(tree_id,is_fertilised,)
VALUES
('$_POST[tree_id]',
'$_POST[is_fertilized]'
)";
but in the db it inserting only 'o' value or some time '1' ? Please suggest how i can store Yes/No instead of 0 &1.Is it a good idea or i need to stick with tinyint itself.
Thanks in Advance!!
Storing Dropdown option value
Moderator: General Moderators
-
pavanesh2009
- Forum Commoner
- Posts: 30
- Joined: Wed Jan 13, 2010 7:24 am
Re: Storing Dropdown option value
yes / no is a boolean. It is the same as 0 / 1 and on / off as well as true / false.
There are only 2 options for your yes / no so using tinyint is fine. Its only 2 options (yes / no) so tinyint (1/0) is fine as its just the corresponding value. Its the same thing just with numbers.
http://cnx.org/content/m19544/latest/
There are only 2 options for your yes / no so using tinyint is fine. Its only 2 options (yes / no) so tinyint (1/0) is fine as its just the corresponding value. Its the same thing just with numbers.
http://cnx.org/content/m19544/latest/