Re: Store array in mysql?
| From: | Sek-Mun Wong | Date: | Thu, 21 Aug 2003 16:16:14 +0000 |
| Subject: | Re: Store array in mysql? | ||
| References: | 1 | Groups: | php.windows |
| Request: | Send a blank email to php-windows+get-21205@lists.php.net to get a copy of this message | ||
use "serialize".
you need to create a table with 2 fields, key & value, where value is a
largetext field.
$str = serialize($array);
mysql_query("insert into table1 (key, value) as ($key, $str)");
then you can select it back out of mysql and use
$result = mysql_query("select....");
$array = unserialize($result[0]->value);
pardon if the php doesn't work, i'm just typing it off the top of my head
"Disko_kex" <disko_kex@swedish-mushroom.com> wrote in message
news:000001c367ec$f7b28340$e900a8c0@lokalguirdcfee...
> If I have a normal array like "Array ( [0] => 1 [1] => 3 [2] => 82 )" ,
> and want to store the array in a mysql table and then want to use it.
> How can I do?
>
> // jocke
>