• I am trying to write a plugin that will manage a football team roster. I have so far been able to create a new table in the database, display the data in a page, and have set up an admin page that will display a selected players data. Beyond that I have been unable to figure out the appropriate way to update my own table. I am sure it is pretty straight forward, but if someone could help me out, maybe with a simple example of how to insert data into a custom table it would really help out. Thanks.

Viewing 2 replies - 1 through 2 (of 2 total)
  • thir13en

    (@thir13en)

    Hello,

    I am looking for something very similar.
    joebou2, did you have any luck?

    MathSmath

    (@mathsmath)

    You’re looking for the wpdb class.

    In your update function, do:

    global $wpdb;

    Then something like this (example taken from the codex article linked above):

    $wpdb->update( 'table', array( 'column1' => 'value1', 'column2' => 'value2' ), array( 'ID' => 1 ), array( '%s', '%d' ), array( '%d' ) )

    Plenty of other examples in the codex article.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘How do I update a custom database table?’ is closed to new replies.