Willkommen, Gast
Angemeldet bleiben:

THEMA:

different data in a select list populate from DB 7 Monate 4 Wochen her #241291

  • yvesfbs Avatar Autor
  • yvesfb
  • Offline
  • Expert Breezer
  • Expert Breezer
  • Beiträge: 180
  • Dank erhalten: 0
Hello,
I have been able to use your example crosstec.org/en/support/online-documenta...ct-list-from-db.html
However, as I am relatively new in coding, I would need some help to modify the
$test .= "0;".$result[$i].";".$result[$i]."\n";

I will take an example if I have a table of Members, instead of the first .$result[$i]. I would like to get for instance the equivalent of the FirstName+ space + LastName information
and instead of the second .$result[$i]. I would like to get the id of the member.

How should I modify your example?
Thanks in advance
yves

Bitte Anmelden oder Registrieren um der Konversation beizutreten.

different data in a select list populate from DB 7 Monate 4 Wochen her #241306

  • TheMuffinMans Avatar
  • TheMuffinMan
  • Offline
  • Developer
  • Developer
  • Beiträge: 10064
  • Karma: 167
  • Dank erhalten: 807
Hi,

it depends on your database table, but let's say you have one column for firstname and another for lastname, it would look like this
$test .= "0;" . $result[$i]->firstname . " " . $result[$i]->lastname . ";" . $result[$i]->firstname . " " . $result[$i]->lastname . "\n";

Be aware that you need to address these columns in your select in order to retrieve them. Usually a wildcard automatically pulls all the columns.

Regards,
Markus

Bitte Anmelden oder Registrieren um der Konversation beizutreten.

different data in a select list populate from DB 7 Monate 4 Wochen her #241312

  • yvesfbs Avatar Autor
  • yvesfb
  • Offline
  • Expert Breezer
  • Expert Breezer
  • Beiträge: 180
  • Dank erhalten: 0
Hi Markus
thank you for the info, but I still some help for the columns. I tried to use the * in the select or to use the field names, but it doesn't load properly the variable.
The number of records is correct in the preview (see attached print screen, I get the 13 lines in the list, which corresponds to the number of records in my table, but the lines of the select list are empty.

the code I have (using the 3 field names I am interested in for the list):
$this->execPieceByName('ff_InitLib'); //Include BreezingForms Library
$db = JFactory::getDBO();//Get Database Object
  
//Create your own query here
$db->setQuery('Select id,title,price From adint_osmembership_plans '); 
  
$result = $db->loadColumn(); //load the result from the query
$test = "";
$test = "0;Please make a selection;0\n";
for ($i = 0; $i < count($result); $i++)
{
     $test .= "0;".$result[$i]->title." ".$result[$i]->price.";".$result[$i]->id."\n";
}
 
function ff_setSelectList($name, $value)
{
     global $ff_processor;
     for ($r = 0; $r < $ff_processor->rowcount; $r++)
     {
          $row =& $ff_processor->rows[$r];
          if ($row->name==$name)
          $row->data2 = $value;
          unset($row);
     } // for
} // ff_setSelectList
 
ff_setSelectList('listepremiumfreemium', $test);

Thanks in advance
yves
Anhänge:

Bitte Anmelden oder Registrieren um der Konversation beizutreten.

different data in a select list populate from DB 7 Monate 4 Wochen her #241337

  • TheMuffinMans Avatar
  • TheMuffinMan
  • Offline
  • Developer
  • Developer
  • Beiträge: 10064
  • Karma: 167
  • Dank erhalten: 807
Hi,

can you please change this
$result = $db->loadColumn();

to this
$result = $db->loadObjectList();

If you use loadColumn, you basically get only the the first column instead of all columns.

Regards,
Markus
Folgende Benutzer bedankten sich: yvesfb

Bitte Anmelden oder Registrieren um der Konversation beizutreten.

different data in a select list populate from DB 7 Monate 4 Wochen her #241372

  • yvesfbs Avatar Autor
  • yvesfb
  • Offline
  • Expert Breezer
  • Expert Breezer
  • Beiträge: 180
  • Dank erhalten: 0
Thank you Markus,
It works fine. :-)
I put the final script here below for info.
Now, I have seen that I need to make second select list based on the result of the first one to make it easier for the user.
Let's say I will use the resulting "id" of the choice made in the first list to filter the elements to insert into the second select list
I have seen that you already provided a script for 2 select boxes in crosstec.org/en/forums/3-breezingforms-f...mboboxes.html#128913
But I have difficulties to combine both scripts due to the fact:
- both elect boxes are built dynamically
- and I don't need to test the result of the first box 'choice1' of your example, but simply to select 2 fields of another table (table2) for the text + the id of that table2 for the value of the row in the select box. it will then be a second formula for the new select list like:
$test2 .= "0;" . $result[$i]->first_name . " " . $result[$i]->last_name . ";" . $result[$i]->id . "\n";

Can you please let me know how to proceed to adapt your example of crosstec.org/en/forums/3-breezingforms-f...mboboxes.html#128913 using the first select box you already helped me with (code below)?

Best regards
yves

Script resulting from the first select box (and stored in the before form):
$this->execPieceByName('ff_InitLib'); //Include BreezingForms Library
$db = JFactory::getDBO();//Get Database Object
  
//Create your own query here
$db->setQuery(Select id,title,price From adint_osmembership_plans); 
  
$result = $db->loadObjectList(); //load the result from the query
$test = "";
$test = "0;Please make a selection;0\n";
for ($i = 0; $i < count($result); $i++)
{
     $test .= "0;" . $result[$i]->title . " " . $result[$i]->price . ";" . $result[$i]->id . "\n";
}
 
function ff_setSelectList($name, $value)
{
     global $ff_processor;
     for ($r = 0; $r < $ff_processor->rowcount; $r++)
     {
          $row =& $ff_processor->rows[$r];
          if ($row->name==$name)
          $row->data2 = $value;
          unset($row);
     } // for
} // ff_setSelectList
 
ff_setSelectList('listepremiumfreemium', $test);

Bitte Anmelden oder Registrieren um der Konversation beizutreten.

different data in a select list populate from DB 7 Monate 3 Wochen her #241732

  • TheMuffinMans Avatar
  • TheMuffinMan
  • Offline
  • Developer
  • Developer
  • Beiträge: 10064
  • Karma: 167
  • Dank erhalten: 807
Hi,

since you and another customer had basically the same requirement, I created a boilerplate form for this task that you can use:

crosstec.org/en/forums/41-breezingforms-....html?start=0#241236

Later in that thread I am extending it to a 4-dimensional selection but I guess based on your description, the 2-dimensional is fine ("make"/"model" relation).

Please check it out and let me know what you think as it might be completely different from what you got so far.

Regards,
Markus

Bitte Anmelden oder Registrieren um der Konversation beizutreten.

Moderatoren: ForumSupport
Ladezeit der Seite: 0.085 Sekunden

Angebot

Sommer Special! Alle Mitgliedschaften zum Sonderpreis!

Prio Support, alle Extensions und alle Templates in einem Paket.

Hier geht's zur Bestellung

Crosstec hilft sparen!

Falls Sie neu bei Crosstec sind aber bereits einen Formulargenerator bei einem anderen Hersteller gekauft haben, dann bekommen sie von uns einen Rabatt von 25% auf unsere 1-Jahres und Pro-Mitgliedschaften

Wie Sie an den Rabatt kommen?

Schreiben Sie uns einfach eine kurze Email mit beigelegten Kaufbeleg (z.B. PayPal Quittung) an sales@crosstec.org.

Wir unterstützen die Joomla Community

Crosstec unterstützt weltweit alle offiziellen Joomla! User Groups und Organisatoren von Joomla! Days die bei Joomla.org registriert sind.

Falls das auf dich zutrifft und du eines unserer Produkte brauchst, schreib uns eine kurze Email an info@crosstec.org und du bekommst eine Flatrate-Mitgliedschaft geschenkt!