how to store multiple checkbox values in database
Posted: Thu Apr 17, 2008 6:27 am
Everah | Please use code tags when posting code in the forums.
hi every1...
i would like to know how to store multiple checkbox values in the database using php n mysql and how to retrieve the same value back from the database?
here is the code...if some one can help me..it would b gr8..
and the php code is
It is presently storing only 1 checkbox values. i would like to know how to store for multiple checkbox values..pls help me
Everah | Please use code tags when posting code in the forums.
hi every1...
i would like to know how to store multiple checkbox values in the database using php n mysql and how to retrieve the same value back from the database?
here is the code...if some one can help me..it would b gr8..
Code: Select all
<html><form method="post" action="checkvalues_test.php"> <input type="checkbox" name="colors[]" value="10" /> Red<br><input type="checkbox" name="colors[]" value="100" /> Blue<br><input type="checkbox" name="colors[]" value="1000" /> Green<br><input type="checkbox" name="colors[]" value="10000" /> Yellow<br><input type="submit" value="submit" name="submit"></form></html>Code: Select all
<?
$ColorsInsert = '*'.implode('*',$_POST['colors']).'*';
mysql_query("INSERT INTO colors(color) VALUES('$ColorsInsert')")or die (mysql_error());
?>Everah | Please use code tags when posting code in the forums.