Basically, I have this line of code:
<?php echo do_shortcode('[O_U user_name="operator"
blocked_message="This page is restricted for guests."]
**Content Goes here** [/O_U]'); ?>
Now, inside Content Goes here I use regular HTML to create my content. But, now, I need to add some php inside that HTML.
Right now, I need to populate the option for select tag with MySQL results.
I have a php code:
<?php
$database_name = "rams";
$mydb = new wpdb(DB_USER, DB_PASSWORD, $database_name, DB_HOST);
$mydb -> show_errors();
//Populate languages
$languages = $mydb -> get_results(
'SELECT * FROM language_skills'
);
foreach ($languages as $language){
//do some echo of html
}
?>
How can I achieve a result here? I now, echo waits for a string there. I thought about heredoc and a custom function, but I can't seem to achieve the result.
UPDATE:
I managed to get my data. It's in an array. How I can show all the array results in above situation?
My array goes something like this:
<option value="$value">$content</option>
It shows exactly what I want when I use:
[shortcode].$array[index].[/shortcode]
How can I add all the indexes? I tried for each but it doesn't work in between shortcodes
ANSWER:
I used implode to change array to a string and code now works as i want.