LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 11-09-2005, 06:20 AM   #1
ALInux
Member
 
Registered: Nov 2003
Location: Lebanon
Distribution: RHEL 5/CentOS 5/Debian Lenny/(K)Ubuntu Is Dead/Mandriva 10.1
Posts: 668
Blog Entries: 7

Rep: Reputation: 31
checkboxes in php [on/off]


Hi
I want to add a checkbox to my form that should act as a on off regulator..........I googled but the only results I found were related to multiple checkboxes.........can anybody tell me how to check if a single checkbox is checked ?
 
Old 11-09-2005, 06:40 AM   #2
fouldsy
Senior Member
 
Registered: Jan 2002
Location: St Louis, MO
Distribution: Ubuntu
Posts: 1,284

Rep: Reputation: 47
Something like this would be in your form:
Code:
<input type='checkbox' name='a1'<?php if( $row["a1"] == '1') { echo "CHECKED"; } ?>>Block / Unblock Website
which is then read in by your processing script as such:
Code:
$a1 = $HTTP_POST_VARS["a1"];
In that case, my script is querying a MySQL database, working out whether an option should be ticked, and then ticking or unticking the check box. Has about 30 options dynamically handled, with the procesing script updating the choices the user makes. You can call it something other than 'a1' and then simply read in your named variable whilst processing. If it's unchecked, the result is 'off', if ticked, the result is 'on'. A quick check to process different commands based on it's value would be:
Code:
if ($a1 === 'on') {
		$a1 = 1;
	}
Hope it helps, otherwise let us know what you're trying to do.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Unsubscribe From [ ] (checkboxes) t3gah LQ Suggestions & Feedback 5 06-02-2005 12:12 PM
php apache or php cgi - php learner rblampain Linux - Security 3 12-17-2004 11:10 PM
Arrays, checkboxes in javascript & PHP Elijah Programming 21 11-15-2004 11:37 PM
Checkboxes in the Subscribed Threads listing Bebo LQ Suggestions & Feedback 2 07-21-2004 09:30 AM
MySQL/PHP - checkboxes etc linuxfond Programming 2 05-07-2004 04:12 AM


All times are GMT -5. The time now is 01:51 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration