NYCPHP Meetup

NYPHP.org

[nycphp-talk] form confusion...

gadhra bfeqx44002 at sneakemail.com
Wed May 14 15:43:49 EDT 2003


You got it - "yn" is just an identifier I use to mean "yes/no".  I use 
them in forms and in database fields so I know what type of value to 
expect in the data field just by looking at the database structure.

So, if I have a table with an entry of:
ynOrderedPizza  

I can either expect a 0 ("No") or a 1 ("Yes")  in that column ie. either 
the person ordered a pizza, or they didn't.  To translate this to a 
checkbox, either they checked the box for "Did you order a pizza?", or 
they didn't.

+gadhra+


Joshua S. Freeman jfreeman-at-amnh.org |NY PHP| wrote:

>Gadhra,
>
>Thanks for the response.  Very helpful.  Please explain what the prefix yn
>means... 'yes/no'? 
>
>Thanks again.
>
>J.
>
>TOn 5/14/03 3:23 PM, "gadhra" <bfeqx44002 at sneakemail.com> wrote:
>
>  
>
>>Hi Joshua,
>>
>>The structural stability field should hold a number (1-x).  For
>>checkboxes, I usually just add yn columns.
>>
>>So, as an example, your table might have the following fields:
>>
>>id (mediumint 5)
>>txtImageName (tinytext)
>>intStability (tinyint 1)
>>ynStorageSupport (tinyint 1)
>>ynInsectActivity (tinyint 1)
>>
>>The intStability field can hold numbers corresponding to the activity (1
>>for "stable", 2 for "slightly stable", etc.). The yn fields hold either
>>a 0 or a 1 - with checkboxes, either something is true (checked) or it's
>>false (not checked).
>>
>>I can very quickly query the table at this point to get the information
>>I need (for image 2, what was the level of its stability?  was there
>>insect activity? was there adequate storage support?)
>>
>>Be careful in naming, of course - the word "inadequate" can create a
>>double-negative connotation if you use ynInadequateSupport (which is why
>>I chose ynStorageSupport instead of its negative).
>>
>>Hope that helps,
>>
>>+gadhra+
>>
>>
>>
>>Joshua S. Freeman jfreeman-at-amnh.org |NY PHP| wrote:
>>
>>    
>>
>>>First off, thanks to the many people who helped me out with my previous
>>>question about making it possible for people to upload images.  I'm not
>>>there quite yet but when I get there I'm sure the answers I received will be
>>>incredibly helpful.  Thanks again.
>>>
>>>I'm working on the same project.. in brief, a scientist has about 1000
>>>specimens of the same kind of thing and wants to make a database containing
>>>a survey of these 1000 specimens.  The main table in the database is the
>>>'specimen'table, but that table has lots of fields for the 'id' number of
>>>records in related tables.
>>>
>>>In most cases, it's clear from the form whether or not I need to build a
>>>table to relate to the main 'specimen' table but in some cases, it's not so
>>>clear.
>>>
>>>Here's an example of what I mean:
>>>
>>>in the form, there's an area called 'structural stability'.  Someone filling
>>>out the form can select for a few radio button:
>>>
>>>-----------snip-----------------
>>>
>>><input type="radio" name="structural stability" value="stable">stable
>>>
>>><input type="radio" name="structural stability" value="slightly
>>>unstable">slightly unstable
>>>
>>>etc...
>>>
>>>---------------snip-------------
>>>
>>>in addition to 4 possible radio buttons, there are also 2 checkboxes
>>>associated with the idea of 'structural stability':
>>>
>>>---------------snip-------------
>>>
>>><input type="checkbox" name="structural stability" value="inadequate storage
>>>support"> inadequate storage support
>>>
>>><input type="checkbox" name="structural stability" value="current insect
>>>activity">   current insect activity
>>>
>>>---------------snip-------------
>>>
>>>so, here's my question:
>>>
>>>right now, i have the name of all the radio buttons and the checkboxes as
>>>'structural stability'
>>>
>>>i'm not sure, however, how to handle this on the database side of things.
>>>Should I give the checkboxes different names and their own tables?
>>>
>>>I'm a little confused at the moment and would love someone with more
>>>experience to shine some light on the path...
>>>
>>>Thanks in advance..
>>>
>>>And rest assured that once I'm done with this project I should be in shape
>>>to begin offering up some advice of my own to new newbies.
>>>
>>>Thanks!
>>>
>>>Joshua
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>> 
>>>
>>>      
>>>
>
>
>
>--- Unsubscribe at http://nyphp.org/list/ ---
>
>
>
>
>
>  
>

-- 
+gadhra+(/s)
*********************
XXXXXXXXXXXXXXXXX
And seize the metropolis;
It's you it's built on





More information about the talk mailing list