wordpress plugin problem

Discussion in 'PHP' started by c4cyber, Jun 6, 2011.

  1. #1
    hi i have to develop a plugin, that
    1-creates a table(i have done that)
    2- develop a plugin settings menu item and page(done that too)
    3- plugin page display a form that takes values from admin (okay so far)
    4- save those values into table(can anyone help here?)

    any tutorial? i have checked few tutorials, but they save and retrieve options. i have other tables where i have to save data via admin panel. not widgets, only plugin.
     
    c4cyber, Jun 6, 2011 IP
  2. Grit.

    Grit. Well-Known Member

    Messages:
    1,424
    Likes Received:
    22
    Best Answers:
    1
    Trophy Points:
    110
    #2
    you'll need to use the database function in your plugin...

    so for your function where you get the data, you will want something like

    
    
    function myfunction(){
    
    global $wpdb;
    
    // something you'll have done to get your data
    
    //now we escape the data
    $wpdb->escape($string);
    
    //create yourself an SQL query to instert your data into the table
    
    //insert the sql
    
    $wpdb->query($SQLQuery);
    
    
    }
    
    
    PHP:
    hope this is of some help...

    by making $wpdb global in your function, you enable the use of the database class, and hence you can use $wpdb->query();

    for more reference, check the wordpress codex for wpdb http://codex.wordpress.org/Class_Reference/wpdb
     
    Grit., Jun 6, 2011 IP
  3. c4cyber

    c4cyber Well-Known Member

    Messages:
    1,040
    Likes Received:
    27
    Best Answers:
    1
    Trophy Points:
    150
    #3
    thx..i got the idea.
     
    c4cyber, Jun 7, 2011 IP