[eluser]Unknown[/eluser]
Hi,
What I’m trying to achieve is to store the following $amenities array-:
array(3) {
[7]=> string(1) "7"
[6]=> string(1) "6"
[8]=> string(1) "8"
}
into the following join table-:
amenities_clubs
================
club_id | amenity_id
Is it possible to break up this array so I can store each array value with it's assoiciated club_id into separate columns, for example:
club_id | amenity_id
=================
12 | 6
12 | 7
12 | 8
13 | 4
13 | 7
I’ve tried to explain my problem best I can with my limited experience, I know this is not an CI problem, but any help would be great.
Rightly or wrongly I've solved this problem with the following code:
Code:
foreach($amenities as $index => $data){
$sql = "INSERT INTO test (club_id,amenities) VALUES ('$CLUB_ID','$index')";
$query = $this->db->query($sql);
}
Thanks,
dizzy