bogu wrote:Maybe I didnt understand u correctly or u didnt explain yourself, but u said How do u intend to add an array into one field without using serialize or implode, and the use explode or unserialized to extract it?
It is entirely possible I am not explaining well. Forgive me... I am totally self taught and dont use the "Lingo"... let me try to clarify....
data comes from a .csv file...
I read the data into a table... the category field is in this format
category1|category2|category3
I then explode that field which creates the array... here is the code I am using...
while($data = mysql_fetch_array($result)){
$categories = $data['CATEGORIES'];
//echo $categories . "<br />";
$category_array = explode("|", $categories);
echo('<pre>');
print_r($category_array);
echo('</pre>');
}
this data has to go into a table with this structure...
CREATE TABLE va_categories
(
category_id
int(11) NOT NULL auto_increment,
parent_category_id
int(11) NOT NULL default '0',
category_path
varchar(255) NOT NULL default '',
category_name
varchar(255) NOT NULL default '',
category_order
int(11) NOT NULL default '1',
is_showing
int(11) default '0',
short_description
text,
full_description
text,
image
varchar(255) default NULL,
PRIMARY KEY (category_id
,category_name
),
KEY category_path
(category_path
),
KEY parent_category_id
(parent_category_id
)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
I need to get the $category_array parsed into the table.
Basically I need to get all the values in the array into the category_name field wth its own unique category_id...
Then I need to get the first level of the array as the parent_category_id and the rest of the array dimensions as the child categories. which is represented in the table in category_path like so
parent_category = 0
child1 = 1
child2 = 2
child3 = 3
0,1
0,2
0,1,3
etc....
I hope this makes more sence...