1
jaerowe
Using XoopsFormSelect with db query
  • 2005/1/14 13:36

  • jaerowe

  • Just popping in

  • Posts: 5

  • Since: 2004/12/29


Hi, i am currently porting some code into the cdbase module. I would like to know how to fill XoopsFormSelect with data directly from the db.

for instance: i use

$sql "SELECT id_gen, des FROM ".$xoopsDB->prefix("cdbase_gens");
$result $xoopsDB->query($sql);


to get the values i want from the database.

I would like to use the returned values (stored in $result) to auto populate the XoopsFormSelect object.

is there an easy way to do this? or must i use a while loop to fill an array and then pass this to the object?

Thanks
jae

2
Mithrandir
Re: Using XoopsFormSelect with db query

A while loop to fill the array, then a
$select_element->addOptionArray($array);

Or
while (list($id$des) = $xoopsDB->fetchRow($result) ) {
     
$select_element->addOption($id$des);
}

3
jaerowe
Re: Using XoopsFormSelect with db query
  • 2005/1/14 13:52

  • jaerowe

  • Just popping in

  • Posts: 5

  • Since: 2004/12/29


spot on & very fast, thank you.

Login

Who's Online

498 user(s) are online (60 user(s) are browsing Support Forums)


Members: 0


Guests: 498


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Oct 31
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits