Check Boxes

Check Boxes

am 29.04.2002 17:32:58 von jcuz

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)

Re: Check Boxes

am 29.04.2002 17:52:15 von Eckhard Hoeffner

* Julio Cuz, Jr. [29 04 02 17:32]:

>Hi--
>
>Does anyone have any suggestions, SAMPLES, or ideas on how to STORE,=20
>RETRIEVE, AND PROCESS values for "Check Boxes" w/PHP & Postgresql?

1.
Use an arry within the HTML-Tags:=20

name=3D"checkbox" value=3D"data[0]"
name=3D"checkbox" value=3D"data[1]"

2.=20
To process with PHP just a simple loop
=09
foreach($array as $var =3D> $value)


--=20
--//--\\--
Eckhard Hoeffner
e-hoeffner@fifoost.org
Tal 44=20
D-80331 München

---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org

Re: Check Boxes

am 29.04.2002 17:58:39 von Surojit Niyogi

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)
>
>



---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/users-lounge/docs/faq.html