Jump to content

php checkbox


Alidad

Recommended Posts

Hi, I'm rookie in php checkbox and I'm trying to understand how to write the code , i have five checkbox in one form like this

 

 

<form action="" method="get"><input name="one" type="checkbox" value="one" />

one<br />

<input name="two" type="checkbox" value="two" />

two<br />

<input name="three" type="checkbox" value="three" />

three<br />

<input name="four" type="checkbox" value="four" />

three<br />

<input name="five" type="checkbox" value="five" />

three<br />

 

</form>

 

 

if checkbox on then show the box, if checkbox is not check, then not show the box, so i understand that need to use zero or one in mysql database in one column called "display".

 

My question is that how can i write the code in checkbox form whether if is zero or one, but how to write code to show DISPLAY OR NOT DISPLAY when reatrieve from mysql database EVEN USING CSS OR NOT.

 

please help thanks.

 

AM

Edited by Alidad
Link to comment
Share on other sites

here is what i wrote in database connection

 

 

include("connect.php");

$query = "SELECT id, display FROM dragdrop";

$result = mysql_query($query);

while($row = mysql_fetch_array($result, MYSQL_ASSOC))

{

 

$id = stripslashes($row['id']);

$display = stripslashes($row['display']);

 

?>

<li id="arrayorder_<?php echo $id ?>"><?php echo $id?> <?php echo $text; ?>

 

 

and in body there is five box and each box has number one number from 1 to five.

 

 

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

 

 

<div id="options">

 

and in checkbox form each checkbox assign to box number and if any box has checkone meaning to display, of not check on meaning not to display

 

<form action="" method="get"><input name="one" type="checkbox" value="one" />

one<br />

<input name="two" type="checkbox" value="two" />

two<br />

<input name="three" type="checkbox" value="three" />

three<br />

<input name="four" type="checkbox" value="four" />

three<br />

<input name="five" type="checkbox" value="five" />

three<br />

 

</form>

 

anyway, I use ajax meaning that every time checkone or not it will automatic update in database right away and refereshe it which is works great, but to display or not to display is i can't figure out ... doe any one can help me!

 

AM

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.