PDA

View Full Version : ¿ can i store ARRAY on mysql database?



noxious
March 26th, 2003, 02:06 AM
newbieee here.. wondering if he can store ARRAY(s) on mysql database? ..and if possible, how can i retieve it using php..:hangover:

ahmed
March 26th, 2003, 02:09 AM
you can use loops :).. i've done that before.. i'll post the script in a sec

noxious
March 26th, 2003, 02:13 AM
woooh! that sounds good! hehhe :)

ahmed
March 26th, 2003, 02:17 AM
myarray = ['ahmed', 'noxious', 'kirupa', 'someone'];
$ii=count($myarray);
mysql_connect('localhost', 'root', 'sesame');
mysql_select_db('dbname');
for($i=0; $i<$ii; $i++){
$entry = $myarray[$i];
$query = "INSERT INTO table_name ( column_name ) VALUES ('$entry');";
mysql_query($query);
}

and to retrieve the data, make a select query (like the one in my sig :P )

noxious
March 26th, 2003, 02:24 AM
yo da man!!! super! lol
thanx man... now i'll try work my way out in loading those arrays on flash... wish me luck! :)


yeah your sig shows what you are... an sql addict? hehehee ;)!

ahmed
March 26th, 2003, 02:26 AM
hehe.. let me know if you needed some more help =)

noxious
March 26th, 2003, 02:48 AM
PHP:--------------------------------------------------------------------------------
$myarray = ['ahmed', 'noxious', 'kirupa', 'someone'];
mysql_connect('localhost', 'root', 'sesame');
mysql_select_db('dbname');
$query = "INSERT INTO table_name ( column_name ) VALUES ('$myarray');";
mysql_query($query);


--------------------------------------------------------------------------------

ahmed, is this possible?

ahmed
March 26th, 2003, 02:53 AM
havent tried it, but i really dont think so..
you can still try it anyways, and let me know =)