Nifa
Dear support,
I really hope you can help me, as this issue is freaking me out here 😉.
One of my extensions allow me to create a custom field type list dropdown select box for their form.
In the configuration component, I get a Values textfield where I can put in the values for that dropdown box.
So manually, you add something like below in that field:
---Select user---
Peter
Randy
Shelly
Junior
However, I want to fill this textfield dynamically based on a POST variable in the URL. Putting the Sourcerer code below in that textfield gets all the right information/names out of the database. However, I cannot get them on separate lines. I get just one dropdown option with the value "Peter Randy Shelly Junior" instead of 4 separate dropdown option lines.
My Sourcerer code looks like:
{source}
<?php
$db =& JFactory::getDBO();
$query= 'SELECT firstname FROM #__my_addressbook where `company`='.$_GET['company'];
$db->setQuery($query);
$result = $db->query();
while ($row = mysqli_fetch_assoc( $result ))
{
echo printf ("%s \r\n", $row["firstname"]);
// My second try to get the next value on a new line
echo nl2br(" \r\n ");
// My third brute force try to get the next value of the while loop on a new line
echo "<br></br><br />";
}
?>
{/source}
I tried a lot with things like \n, \rn, echo "<br>", nl2br() etc. But on all those tries I get a dropdown with all the right SQL information but in only one selection "Peter Randy Shelly Junior" instead of four.
Hope you can help me to get the names vertical, instead of horizontal, in the dropdown selection Values textfield.
With thanks in advance, Nico