Page 1 of 1

MySQL and PHP Variables

Posted: Sat Nov 19, 2005 4:03 pm
by illuminationed
Hi!i!i!i!i!i!i!i

I am having difficultly with code i am *trying* to make but need help with this feature:

I want to have 10 variables, store them in a mysql database (in the same column), extract the data and create 10 new variables

This is for a top 10 favourite links (different for each user). I have user data already stored in a table, i could add 10 more columns to the database but i know it is possible to store the data in one column!!

Help?? :?

Posted: Sat Nov 19, 2005 4:11 pm
by php3ch0
you need to use arrays and serialize()

Code: Select all

$foo=serialize($array); 

$query=INSERT INTO sql_table VALUES('$foo');


you can then use unserialize() to convert the data from the table back into an array.

Posted: Sat Nov 19, 2005 4:14 pm
by illuminationed
Thanks I will try it out now!!

Thanks

Posted: Sat Nov 19, 2005 5:54 pm
by Jenk
A correction to php3cho's reply:

Code: Select all

<?php

$foo=serialize($array);

$query="INSERT INTO sql_table VALUES('$foo')";

?>

Posted: Sun Nov 20, 2005 3:25 am
by illuminationed
Thanks For Your Help!!

Posted: Mon Nov 21, 2005 2:25 am
by php3ch0
sorry.