PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
tags when posting code. Read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]
can you store an array in a mysql db, and retrieve it and use it as an array? (does the field need to be TEXT or something special?)
when i use phpmyadmin i see the value is Array basically saying i have an array stored in there -- that's fine. when i pull it out and echo it, i get Array again; that makes sense.
if i count($array) i get 1, or whatever number of items it has.
however, when i try to loop the array it doesn't run the loop. any ideas??
see code:
while($question = mysql_fetch_object($run_form_data))
{
while($chosethis = mysql_fetch_object($run))
{
$here = eval("return \$chosethis->question_{$question->formdataid};");
print $here; // prints "Array"
print count($here); // prints "1"
foreach($here as $temp)
{
print "[".$temp."]"; // is never run, i never see "[]"
}
}
}
you're storing the string, "Array", nothing more.. use [php_man]serialize[/php_man]() to compact the array into a string. To expand it back, use [php_man]unserialize[/php_man]().
thanks - i dont think im storing a string ... im storing ... i have checkboxes with the same name, when submitted php creates an array, correct? that's what's stored.
i'll try what you recommended and that sounds like it'll work.
sorry for not using <?php ?> -- this being a PHP site i thought i could omit them