/    Sign up×
Community /Pin to ProfileBookmark

php check box

hi, Im rookie in php checkbox trying to understand how this works.
I create five squares boxes and each box has value number 1 to five
using this code

[CODE]<div class=”sidebar1″>
<ul class=”nav”>
<li><a href=”#”>Link one</a></li>
<li><a href=”#”>Link two</a></li>
<li><a href=”#”>Link three</a></li>
<li><a href=”#”>Link four</a></li>
</ul>[/CODE]

and then i created five check box and each each box has same number assign to the square box number

[CODE]<form action=”” method=”get”><input name=”one” type=”checkbox” value=”1″ />

one<br />
<input name=”two” type=”checkbox” id =”box_two” value=”1″ />
two<br />
<input name=”three” type=”checkbox” id =”box_three” value=”1″ />
three<br />
<input name=”four” type=”checkbox” id =”box_four” value=”1″ />
three<br />
<input name=”five” type=”checkbox” id =”box_five” value=”1″ />
three<br />

</form>[/CODE]

and then if check box is checked set value to one, if not check then set value to zero and update into the database…
here what i wrote..

[CODE]<?php
$box_one = “1”;
$box_two = “1”;
$box_three = “1”;
$box_four = “1”;
$box_five = “1”;

if($box_box1 == 1) { $set_checked = ” 1″;}
else{$set_checked = “0”; }

if($box_two == 1) { $set_checked = ” 1″;}
else{$set_checked = “0”; }

if($box_three == 1) { $set_checked = ” 1″;}
else{$set_checked = “0”; }

if($box_four == 1) { $set_checked = ” 1″;}
else{$set_checked = “0”; }

if($box_five == 1) { $set_checked = ” 1″;}
else{$set_checked = “0”; }

?>[/CODE]

So how can i write the code if any field in database set value 1 in database then display the box, if any field in database set value 0 and not to display box using css or jquery.

how can i write that code!

AM

to post a comment
PHP

0Be the first to comment 😎

×

Success!

Help @Alidad spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...