SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Thread: PHP arrays

  1. #1
    SitePoint Zealot CalebMingle's Avatar
    Join Date
    Jul 2007
    Posts
    135
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    PHP arrays

    Okay, I am working a little with Mootools JS framework and I am trying to submit an AJAX form.

    Here is my current ajax.php (form);
    http://development.calebmingle.com/myspace/ajax.php

    It sends the posted data to ajax.form.php

    heres ajax.form.php:
    PHP Code:
    <?php
    print "<pre>".print_r($_POSTtrue)."</pre>";
    ?>
    I need to put all the info in the array in a database, how could I do this?
    :: Caleb Mingle (@dentafrice)
    :: PHP Developer.
    :: g+: http://gplus.to/mingle

  2. #2
    SitePoint Addict CommanderZ's Avatar
    Join Date
    Apr 2006
    Location
    Czech Republic
    Posts
    236
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You should be able to serialize it or if you have corresponding db structure, you could do something like this:

    Code PHP:
    $query="INSERT INTO table SET "
    foreach ($_POST as $key=>$val){
     $query.= $key."=\"".$val."\" ";
    }
    Mysql_query($query) or die("ERROR");

  3. #3
    SitePoint Zealot CalebMingle's Avatar
    Join Date
    Jul 2007
    Posts
    135
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    works! thanks.

    I usually try to debug stuff like this myself.

    I found you can just use $_POST[field_name]; didn't think that would work though with ajax.

    stupid me.
    :: Caleb Mingle (@dentafrice)
    :: PHP Developer.
    :: g+: http://gplus.to/mingle


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •