1
xsell
XoopsFormSelect Array with db query
  • 2010/2/11 7:13

  • xsell

  • Quite a regular

  • Posts: 245

  • Since: 2008/9/2 1


HI

How to fill XoopsFormSelect with data directly from the db.

I need to get the Category Name in Drop Down Select Option ..

This wht i tried .. but it Only Brings One Category Name ..

$sql "SELECT cat_id,cat_name FROM ".$xoopsDB->prefix("test_category");
$result $xoopsDB->query($sql);

while (list(
$cat_id$cat_name) = $xoopsDB->fetchRow($result) ) {
$select_element = new XoopsFormSelect('''cat');
     
$select_element->addOption($cat_id$cat_name);

}
          
$form->addElement($select_element);


2
ghia
Re: XoopsFormSelect Array with db query
  • 2010/2/11 8:02

  • ghia

  • Community Support Member

  • Posts: 4953

  • Since: 2008/7/3 1


Try with:
$select_element = new XoopsFormSelect('''cat');
while (list(
$cat_id$cat_name) = $xoopsDB->fetchRow($result) ) {
     
$select_element->addOption($cat_id$cat_name);
}
In your code the select_element gets every time recreated in the loop.

3
xsell
Re: XoopsFormSelect Array with db query
  • 2010/2/11 8:46

  • xsell

  • Quite a regular

  • Posts: 245

  • Since: 2008/9/2 1


Thx Ghia ... .. I dont know how i couldt See that .. :)

Login

Who's Online

389 user(s) are online (272 user(s) are browsing Support Forums)


Members: 0


Guests: 389


more...

Donat-O-Meter

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

Latest GitHub Commits