Current location: Hot Scripts Forums » Programming Languages » PHP » Serializing a set of arrays

Serializing a set of arrays

 
Prev Previous Post   Next Post Next
  #1 (permalink)  
Old 10-10-04, 01:07 PM
dannyallen dannyallen is offline
Newbie Coder
 
Join Date: Jun 2004
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Serializing a set of arrays

I am trying to serialize a table from my database, which is named "fcc_templates". Now, I want the output from the database to be like this:


Array
(
[1] => Array
(
[template_1] => Array
(
[tid] => 1
[skinid] => 1
[name] => Installed Correctly
[template] => testing $var
[callname] => install_correct
)
[template_2] => Array
(
[tid] => 1
[skinid] => 1
[name] => Installed Correctly
[template] => testing $var
[callname] => install_correct
)
[template_3] => Array
(
[tid] => 1
[skinid] => 1
[name] => Installed Correctly
[template] => testing $var
[callname] => install_correct
)

)

[2] => Array
(
[template_1] => Array
(
[tid] => 1
[skinid] => 1
[name] => Installed Correctly
[template] => testing $var
[callname] => install_correct
)
[template_2] => Array
(
[tid] => 1
[skinid] => 1
[name] => Installed Correctly
[template] => testing $var
[callname] => install_correct
)
[template_3] => Array
(
[tid] => 1
[skinid] => 1
[name] => Installed Correctly
[template] => testing $var
[callname] => install_correct
)

)

)

Each number [1] etc is a skin set id, and the templates are by their name. Now, I can get my script to output this:

Array
(
[1] => Array
(
[install_correct] => Array
(
[tid] => 1
[skinid] => 1
[name] => Installed Correctly
[template] => testing $var
[callname] => install_correct
)

)

)

But, as you can see, only one template is shown. I want to be able to show all the templates in the [1] array or [2] array or whatever number the skin id is. Here is the code I have so far:

$value = $db->query("SELECT * FROM fcc_templates");
while ($cache1 = $db->fetch_array_assoc($value)){

$newval = array ($cache1[skinid] => array($cache1[callname] => $cache1));

$val .= serialize($newval);

}

echo $val;

echo "<br><br><pre>";
$new1 = unserialize($val);
print_r($new1);
echo "</pre>";

and the serialization seperates each template into its own array. I want each template to be part of the entire skinid array, not it's own big array. Here is what it looks like:


Array
(
[1] => Array
(
[install_correct] => Array
(
[tid] => 1
[skinid] => 1
[name] => Installed Correctly
[template] => testing $var
[callname] => install_correct
)

)

)


Array
(
[1] => Array
(
[next_template] => Array
(
[tid] => 1
[skinid] => 1
[name] => Installed Correctly
[template] => testing $var
[callname] => install_correct
)

)

)

see, each template is in its own array. How can I fix this?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Share on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
 

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to set usr/pswd for localhost phpMyAdmin steezjjc PHP 3 10-11-04 07:52 AM
Understanding Arrays rjwebgraphix PHP 11 09-27-04 03:06 PM
java set random weight in instance joebloggs2004 Everything Java 1 09-24-04 10:37 AM
Set List Prediction Request ToasterBoy Script Requests 3 09-23-04 02:56 AM
is there command like SET FILTER TO websmart PHP 3 09-07-04 12:53 PM


All times are GMT -5. The time now is 12:02 PM.
vBulletin® Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.