Retrieve data from db and show in dynamic select
-
Hello and thank you for this great plugin.
I have a question about dynamically populating a select with data retrieved from the database.
After a series of queries, I arrive at the table where I find the user’s name, surname and email.
The purpose is to populate the select with something like this
<option value="'.$email.'">'.$first_name.' '.$last_name.'</option>'
This is my code
$result = $wpdb->get_results("SELECT * FROM mytable WHERE id = $customer_id"); foreach($result as $row) { $first_name = $row->firstName; $last_name = $row->lastName; $email .= $row->email; return '<option value="'.$email.'">'.$first_name.' '.$last_name.'</option>'; }
But with return i’ll get only one result, how can i get and populate select with alle result?
Thank you
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘Retrieve data from db and show in dynamic select’ is closed to new replies.