0

After lots of searching and failing after trying.. i am posting this question here..

After half part of my actual query [here][1] i am not able to save the resulting array of arrays to the database..

Initially i had an array of inputs which i turned into array of arrays of inputs now my save function looks something like this

function store()
{
        foreach($post['cats'] as $cat)  {

        $query = 'insert into #__joomd_item_cat values('.$cat.', '.$row->id.')';
        $this->_db->setQuery( $query );

        if(!$this->_db->query())    {
            $obj->error = $this->_db->getErrorMsg();
            return $obj;
        }

    }
}

now, how do i modify it to get my array of arrays into database..

This function is triggered by a serialized method.. so please recheck your answers and comments

function save(task) {
var data = $jd("form[name='<?php echo $array['editform']; ?>']").serializeArray();
    $jd.ajax({
          url: "<?php echo $url; ?>",
          type: "POST",
          dataType:"json",
          data: data,
          beforeSend: function()    {
            $jd(".poploadingbox").show();
          },
          complete: function()  {
            $jd(".poploadingbox").hide();
          },
          success: function(res)    {

            savesuccess(res);

          },
          error: function(jqXHR, textStatus, errorThrown)   {
            alert(textStatus);                 
          }
    }); 

}

  [1]: http://stackoverflow.com/questions/11583375/add-input-fields-dynamically-but-fields-are-generated-by-external-php-functions/11583597#11583597
2
  • 2
    The easy way is to serialize (see serialize(), php.net/serialize) your array and save that, but it limits your ability to manipulate the data in the database. Commented Jul 20, 2012 at 19:52
  • all i can figure out is use the function serialize() which cab be used like type:serialize($_POST); in ajax in the sending function, but retrieval is still not clear.. To save them i still need an array, which all confuses me.. Can you help Commented Jul 21, 2012 at 4:59

1 Answer 1

3

You can serialize() it and then unserialize() it upon retrieval.

Sign up to request clarification or add additional context in comments.

2 Comments

Being a learner of the basics, all i can figure out is use the function serialize() which cab be used like type:serialize($_POST); in ajax in the sending function, but retrieval is still not clear.. To save them i still need an array, which all confuses me
Am sorry, the things were already serialized, now how would you want me to proceed..

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.