WordPress.org

Ready to get started?Download WordPress

Forums

Contact Form DB
[resolved] [Plugin: Contact Form 7 to Database Extension] Columns Swapping During Export (4 posts)

  1. tender82
    Member
    Posted 3 years ago #

    I'm not sure why this is happening, but I had this set up yesterday and pulling data. Today, the columns have swapped. I'm not sure why.

    Any ideas?

    Thanks,
    Tim

  2. Michael Simpson
    Member
    Plugin Author

    Posted 3 years ago #

    Thinking about this: a form submission column_name-value pairs are inserted into a database row in the order that they appear on the data HTTP POSTed from the form. That should be in the order they are listed in the form. From that, when they are read out for display, they are just read in the order that they are returned from the database query (which does not sort). No explicit attempt to order them my column is made but they are ordered by submission date. So generally speaking you should see columns listed in the same order as the *first* form submission in the database appears. I think if you re-order fields in the form but have data in the DB already, then the order would not change. But if you did that then deleted the first form submission in the DB, then the second one in the DB may be in a different order so you would see a change. Then again, since the MySQL query is not sorting on columns (but is sorting on submission date) it could conceivably return data in different column order based on its own internal algorithms...

    I will put on my to-do list to write code to at least make the order deterministic.

  3. Michael Simpson
    Member
    Plugin Author

    Posted 3 years ago #

    As of version 1.4, the order of columns in the form is tracked explicitly. So you will see the columns in the order that the fields were in the last submitted entry. If you change the order on the form, that will be reflected as soon as someone submits that form using that order.

  4. tender82
    Member
    Posted 3 years ago #

    Awesome. Thank you for the quick work. It didn't swap columns much, but with my excel program, it would break every time it did.

    Thank you again.

    Tim Tender
    Meteorologist
    WJAC-TV
    Johnstown, PA

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic