PHP Questions Home | Register | Login
Categories
Arrays
Files
Forms
Creating PDFs
PHP Errors
Functions
Images
MySQL
Numbers
Others
Strings
Website
Unanswered

PHP Forums
Forums Index
MySQL Forum
PHP Forum
Flash/Actionscript
Javascript
Web design

More PHP
PHP Functions
Top Questions
Ask a Question
PHP Interview Questions
PHP Jobs
Ecommerce
IT Questions
Business Websites

Sponsors

sponsor ad
My Salary
PHP Developer Salary
Advertise Here

how can i put the value 1 or 0 into checkbox if we checked then 1 otherwise 0?


This can be done fairly straightforwardly.

If you want to tick a box depending on the input to the form when re-echoing out that form, then you simply see whether it is set to 1 or 0 in your code.

You then echo the box to being checked when you write the code, depending on the value, e.g. like this:

<?php
$checked 
$_POST[checked];
//this contains 1 if the box was checked and 0 otherwise

echo "<form action='blah.php' method='post'>
This checkbox will be ticked if you selected it on the previous page:"
;
echo 
"<input type='checkbox' name='checked'";
if(
$checked) { echo "CHECKED"; }
echo 
">";
echo 
"<input type='submit' name='submit' value='send form'>";
echo 
"</form>";
?>



Comment on this Question and Answer >>>

ASK A QUESTION

More other PHP Questions

Can I include Javascript in my PHP code?

What does the @ character do in PHP?

Can PHP create PDF files for me?

What are autoglobals?

Can I spellcheck my text using PHP?



Custom Search