Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

databases

Status
Not open for further replies.

deathcaster

Programmer
Dec 28, 2002
1
US
Does anyone know how to get info out of checkboxes using php. Any answers are welcome

Thnx in advance! :)
 
Any way you could post the code for the checkboxes, as well as what you'd like to do with the ones that are checked, database-wise?

 
deathcaster:
Checkboxes work a lot like any other HTML form field -- each takes a name (using the name= attribute) and a value (using the value= attribute).

The difference between checkboxes and other form fields is that if a checkbox is not checked, it will not return a value.

ingernet:
Two things:

It's considered impolite to piggyback on another user's question.

Insufficient data for a meaningful answer. "database-wise" is nowhere near enough information about your project to even begin to advise you. Want the best answers? Ask the best questions: TANSTAAFL!
 
And don't forget you can have multiple check boxes with the same name, in which case they become an array, and you can extract the data that way... personally I find this very useful.

-Rob
 
Also to deathcaster: try to make the title of your threads more specific. 'Databases' could mean anything. Better to title it 'Storing checkbox data in a database'. Interestingly enough, that's almost exactly the title of this PHPBuilder article:
Enjoy ;-) -------------------------------------------

Big Brother: "War is Peace" -- Big Business: "Suspicion is Trust"
(
 
one easy way to see what the value is for a checkbox is pass the values using the GET method...you end up with the 'elementname=on' or 'elementname= '

generally what i do then is convert the value to 1 for on and 0 for uncheck or off...then store the value 1 ro 0 in the db as a tinyint...

hth Bastien

There are many ways to skin this cat,
but it still tastes like chicken
 
sleipnir214, i wasn't piggybacking. i was asking for more data so that i could help deathcaster. there's a good chance that i have code that would be useful, but i need to know what deathcaster wants to do, which is why i asked such an open-ended question. sorry if that wasn't clear.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top