hi to all,
i have created a table named as "content".... it has 4 columns "id", "page_name", "brows_title" and "content_title" . .
now i have an array of page names as
$pages=array("index.php","about.php","contact.php","laptop.php","printers.php");
now please tell me,how to insert this array into "content (page_name)"
how to insert an array into one field of any table
Moderator: General Moderators
-
mianmajidali
- Forum Commoner
- Posts: 30
- Joined: Tue Dec 01, 2009 8:05 pm
-
cpetercarter
- Forum Contributor
- Posts: 474
- Joined: Sat Jul 25, 2009 2:00 am
Re: how to insert an array into one field of any table
You can serialize the array, and then place it in the database. When you retrieve information from the field, you can unserialize it to restore the original array.
-
mianmajidali
- Forum Commoner
- Posts: 30
- Joined: Tue Dec 01, 2009 8:05 pm
Re: how to insert an array into one field of any table
thanks alot dear, i m also trying to do this using implode() and explode()
-
rahulzatakia
- Forum Commoner
- Posts: 59
- Joined: Fri Feb 05, 2010 12:01 am
- Location: Ahmedabad
Re: how to insert an array into one field of any table
Hi,
you can use the following code for this..
and now you can use the $pages1 when inserting into database of "content (page_name)";
Similarly you can use the explode function when you want to retrieve it from the database.
you can use the following code for this..
Code: Select all
$pages=array("index.php","about.php","contact.php","laptop.php","printers.php");
$pages1 = implode(",",$pages);
Similarly you can use the explode function when you want to retrieve it from the database.
-
mianmajidali
- Forum Commoner
- Posts: 30
- Joined: Tue Dec 01, 2009 8:05 pm
Re: how to insert an array into one field of any table
thanks of all colleagues, i have done this using implode and explode.