Simply in search of a bit of recommendation on find out how to deal with this:
Up to now (many moons in the past) once I did the occasional php/mysql work, it was comparatively straightforward to tug/show information from a desk utilizing the desk header within the “WHERE” question. (i.e. SELECT * FROM ‘desk’ WHERE ‘column-name’ = ‘question’).
The tables would have columns for every bit of knowledge resembling e-mail, telephone, deal with, and many others.
I’m presently engaged on a challenge utilizing a desk that was put in into the database by a plugin the place I need to use a few of that information in a special space of the positioning not associated to the plugin.
As a substitute of a column for every sort of knowledge as above, this desk has
- a user_id column which is linked to the customers wordpress account
- user_id a meta_key column. This column has entries resembling deal with, telephone quantity, and many others. (these can be the column names in my above instance)
- a meta_value column. This column holds the information for every sort of meta_key (the precise deal with, telephone quantity, and many others.)
What I’m trying to do is get the worth for every merchandise for a specific user_id and pre-fill a kind that’s submitted.
So their Consumer ID, Title and e-mail are pulled from the customers desk of the WP database when they’re logged in utilizing the wp_get_current_user() operate.
As soon as I’ve the Consumer ID, I then need to show that consumer’s deal with, telephone quantity and many others from the opposite desk in my kind however I am caught on the sql question
One thing like:
world $wpdb; $current_user = wp_get_current_user(); $uid = $current_user->ID; $desk = $wpdb_>prefix . 'plugin-table';
I then need to choose the consumer’s deal with and telephone quantity and many others and show them as particular person items of information, so:
$cellular $deal with $studentnumber
in order that I can use them the place wanted
What can be the proper solution to question the database to get the information I am in search of?
Hope that every one made sense…