//get value from a form with comma separated
$formValues = $_POST['prtype'];
//make array be comma delimeter
$alltype = explode(',' ,$formValues);
//use serialize function to put that value to mysql database
$newValues = serialize( $alltype);
//insert into database
$sql = "mysqli_query( col1, col2 ) VALUES ('val1', ' ".$newValues." ' )";
mysqli_query($conn, $sql);
//get the data from database
$query_result = mysqli_query($conn, "SELECT * FROM products where p_id = '6' ");
$row = mysqli_fetch_assoc($query_result);
//it return the array
$retrieved_value = unserialize($row['col2']);
0 Comments