I have table named user with this structure
userid (PrimaryKey) | Names | Email | Phone# |
Then i have a table 2 named investment with this structure
invid (PrimaryKey)(AI) | userid (ForeignKey) | capital | commission | date | upliner | status defaul(0)
I need when i insert a record in table 2 the foreign key should be linked with table 1, This below is INSERT code i'm using
$output = $wpdb->insert ( 'investment', array( 'capital' => $fields['capital'], 'commission' => $fields['commission'], 'date' => $fields['date'], 'upliner' => $fields['upliner'], ));
Code to retrieve logged userid
global $current_user;
get_currentuserinfo();
$value1 = $current_user->ID;
$value1 will be holding ID number of logged in user because it is the foreign key in investment table.
So basically i want the data to be inserted where the current logged in userid $value1=userid