WordPress.org

Ready to get started?Download WordPress

Forums

$wpdp->insert or update for poll plugin? (2 posts)

  1. smileX
    Member
    Posted 2 years ago #

    Hi!

    Working on a sort of a poll plugin. On each anwser in the poll there is a "vote" submit button that is connected with the answers ID.

    At first, I used the $wpdp->update to increase the value by one. With that solution the submit button only worked once per answer. Don´t know the reason for that though.

    Another member at this forum helped me out and said I should use the £wpdp->insert method instead, when I tried that some new rows where added to the table.

    So, my question is, how do I write a ->insert statement that only increases the value? Or, how do I write a update ->update statement that can be used more than once.

    If you have any questions about my database setup or similiar, tell me! =)

    Thanks! Regards.

  2. bcwp
    Member
    Posted 2 years ago #

    Hi, smilesX. You would only use an insert statement to insert new records. To change an existing record, you would use an update. If you post your table structure (i.e. the columns and data types), your current code for inserting and updating, and explain how it works, I'll see what I can do.

Topic Closed

This topic has been closed to new replies.

About this Topic