J
J
Jupiter Max2018-03-14 09:35:50
WordPress
Jupiter Max, 2018-03-14 09:35:50

How to retrieve data from Wordpress database?

Hello!
I have a table in a db created by me, it stores some data. How to make a request correctly in order to display data in the required fields. Now I do this:

$vdusersdataemail = $wpdb->get_var("SELECT user_email FROM wp_vd_users WHERE user_login = '".$_SESSION['login']."'"); 
<input type="text" name="email" value=" echo $vdusersdataemail; " class="custom-text grey-text" />

And thus, I need to display other data in a few more fields. But it seems to me that I am doing something wrong if I make a separate request to the database for each field.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Igor Vorotnev, 2018-03-14
@vardoLP

Read the documentation , or something ... Well, or at least open the class and see what public methods it has.
$wpdb->get_var()is to get one particular value.
$wpdb->get_row()- to get the entire string.
$wpdb->get_results()- more general, generic, for obtaining any results.
$wpdb->query()- in general, to fulfill any request.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question