pg.ddx.io  pgsql-php@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Surojit Niyogi <surojit@bungeecode.com>
To: Julio Cuz, Jr. <jcuz@rccd.cc.ca.us>
Cc: php-db@lists.php.net
Cc: pgsql-php@postgresql.org
Subject: Re: Check Boxes
Date: Mon, 29 Apr 2002 10:58:39 -0500
Message-ID: <3CCD6DAF.6060005@bungeecode.com> (raw)
References: <5.1.0.14.0.20020429083154.00a89760@mail.rccd.cc.ca.us>

Julio,

The way I see it checkboxes are just boolean graphical representations. 
 Either a "yes" or "no" value if the box is checked or not, 
respectively.  Hence, it would make sense for the field to be of type 
"bool".  As far as storing goes, PHP sees a checked box of having a 
value of "on" and an unchecked box of having a value of false (or 
empty).  So what I typically do is have a function called is_checked() 
that passes the form field.

function is_checked($form_field){
    global $HTTP_POST_VARS;
    if($HTTP_POST_VARS[$form_field[ == "on")
        return 1;
    else
        return 0;
}

In my SQL statement I pass the returned value directly

$strSQL = "INSERT INTO blah (is_foo) VALUES (" . is_checked('is_foo') . ")"

Hope this helps. :D

-Roj Niyogi
Founder
pgHoster
PostgreSQL web hosting

http://www.pghoster.com

Julio Cuz, Jr. wrote:

> Hi--
>
> Does anyone have any suggestions, SAMPLES, or ideas on how to STORE, 
> RETRIEVE, AND PROCESS values for "Check Boxes" w/PHP & Postgresql?
>
> Thanks!
>
> Julio Cuz, Jr.
> Riverside Community College
> jcuz@rccd.cc.ca.us
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 2: you can get off all lists at once with the unregister command
>    (send "unregister YourEmailAddressHere" to majordomo@postgresql.org)
>
>





view thread (3+ messages)

Message-ID: <3CCD6DAF.6060005@bungeecode.com>
Permalink:  ../3CCD6DAF.6060005@bungeecode.com/
Also on:    postgresql.org/message-id/3CCD6DAF.6060005@bungeecode.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-php@postgresql.org
  Cc: surojit@bungeecode.com, jcuz@rccd.cc.ca.us, php-db@lists.php.net
  Subject: Re: Check Boxes
  In-Reply-To: <3CCD6DAF.6060005@bungeecode.com>
  References: <5.1.0.14.0.20020429083154.00a89760@mail.rccd.cc.ca.us> <3CCD6DAF.6060005@bungeecode.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox