I am creating a SELECT
drown down list, I would like to have it loaded in 1 of 2 ways.
First way is pulling data from database with ID, name, and Value - This way will be loaded from other pages.
Second way, I would like to load from a Single line in the database with Name and Value. But I want to have that value be loaded with an array.
How do I load that array into the database?
$name = 'name';
$value = array( 'red' => 'Red', 'blue' => 'Blue' );
$SQL = 'INSERT INTO table_name (name, value) VALUES ($name,$value);
I expect when I run the SELECT * from table_name WHERE name = "name"
to use that array in the value field right away.
With what "RakeshJakhar" said, to use the implode and explode onto $value
$value = array( 'red' => 'Red', 'blue' => 'Blue' );
print_r( $value );
echo "<br />";
echo implode( ",", $value );
echo "<br />";
$implode = implode( ",", $value );
$explode = explode( ',', $implode );
print_r( $explode );
Results:
Array ( [red] => Red [blue] => Blue )
Red,Blue
Array ( [0] => Red [1] => Blue )