Web Hosting
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

WordPress fix Reply To: How to insert data using PHP/WordPress?

Discussion in 'Misc WordPress Requests' started by dineshkashera, Oct 23, 2017.

  1. dineshkashera

    Guest

    Reply To: How to insert data using PHP/WordPress?, by dineshkashera

    Hello,
    You don’t need to create connection in wordpress before every query because it already done in wp-config.php file at root wordpress folder. you need to use wordpress query structure instead to use php core query.

    we create query using global object $wpdp.

    To insert a row you must create query by use below code
    Insert two columns in a row, the first value being a string and the second a number:

    $wpdb->insert(
    'table',
    array(
    'column1' => 'value1',
    'column2' => 123
    ),
    array(
    '%s',
    '%d'
    )
    );

    To get more help, please visit this link
    https://codex.wordpress.org/Class_Reference/wpdb

    Thanks

    Reply To: How to insert data using PHP/WordPress?
     
    #1

Share This Page

Web Hosting