MySQL Database Php

// This code is useful for multiple checkboxes. I'm using array facility with in this code.


Code:

Red
Blue
Green
Megenta



// In MySQL, pls make one table i.e.
// colors: (colorcode varchar(20), colorname varchar(20));
//declare information for database connectivity
mysql_connect(localhost,username,pwd);
mysql_connect_db(databasename);
$ecode = $_POST['code'];
$ec = $_POST['colors'];
//this function store ur values on the table.
function print_selected_values($e_code,$area_array) {
foreach($area_array as $color_value){
$query = "insert into colors(colors,code)values('$color_value','$e_code')";
$result = mysql_query($query) or die ("query not made");
}
print("entry successfully made....!");
}
print_selected_values($ecode,$ec);
?>