0 Replies Latest reply on Jan 18, 2010 6:19 AM by zzipper7

    MySQL results to array for string or varible for other table insert

    zzipper7 Level 1

      Hi all,


      I hope I’m in the right Forum, there are so many now.


      I’m using my DB as a cart with each row having an item. I want to pull all of the rows into one array or string to add to another table.


      I have a While loop that


      while ($row_cart = mysql_fetch_assoc($cart))


          foreach ($row_cart as $item)


                      $array[] = $data[];



      print_r($array)  OK  -one big array


      So all my data is in one array (multi-dimensional) I assume.


      The kicker is, when I serialize it, then unserialize it…the unserialzed array prints fine....but its blank if I try to implode it.


      $save_string = base64_encode(serialize($thisrow));



      print_r($undo) OK  -one big array


      Many failed attempts to break this down so I can implode in to a string:


      $mydata = $undo;

      for ($i=0;  $i<$itemcount; $i++) {

      print_r($mydata) . ' | ';


      Prints:  Array| Array| Array| Array|


      I have many other attempts, I’m able to count the array elements, but when its time to implode to a string, it always prints empty. "|||||||"



      I think my problem is in the loop, I’m not setting up the right array. Thoughts anyone??