> How would I store an array in the database? I want to store 2 things.
> One array of shirt sizes and one array of which holds other arrays.
Easy.
<script language="php">
$singleDimArray = array( 1, 2, 3, 4, 5 );
$multiDimArray = array( array( "this" => "that", "here" => "there" ),
array( "near" => "far", "wherever" => "you are" )); // hehe
$query = "INSERT INTO table
( field1, field2 )
VALUES
( \"" . serialize( $singleDimArray ) . "\", \"" . serialize(
$multiDimArray ) . "\" )";
$result = mysql_query( $query );
$selectQuery = "SELECT * FROM table";
$result = mysql_query( $selectQuery );
$fetchedRecord = mysql_fetch_assoc( $result );
$singleDimArray = unserialize( $fetchedRecord['field1'] );
$multiDimArray = unserialize( $fetchedRecord['field2'] );
</script>
serialize() is your friend when it comes to storing arrays in
a DB field.
Chris
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php