1
kaotik
Dropdown, query DB not working
  • 2004/10/6 0:21

  • kaotik

  • Just can't stay away

  • Posts: 861

  • Since: 2004/2/19


HI, I've been tring to populate a dropdown, but can't seem to get the db query to work. Here's what I have:

le="color: #000000"><?php $results = 'SELECT account FROM ' . $xoopsDB->prefix('wmfx_popsettings') . ' WHERE id = '1''; $select_str = ""; while ($opt = $xoopsDB->fetchArray($results)) { $sel = $opt['account']; $select_str .= "<OPTION VALUE='$sel'>$sel</OPTION>n"; } echo "test"; echo $select_str; echo "test";


Can someone help me?

2
Dave_L
Re: Dropdown, query DB not working
  • 2004/10/6 0:30

  • Dave_L

  • XOOPS is my life!

  • Posts: 2277

  • Since: 2003/11/7


You forgot to do the query.

le="color: #000000"><?php $results = $xoopsDB->query(' SELECT account FROM ' . $xoopsDB->prefix('wmfx_popsettings') . ' WHERE id = '1' ');

3
kaotik
Re:Dropdown, query DB not working
  • 2004/10/6 0:53

  • kaotik

  • Just can't stay away

  • Posts: 861

  • Since: 2004/2/19


I replaced this line:
le="color: #000000"><?php $results = 'SELECT account FROM ' . $xoopsDB->prefix('wmfx_popsettings') . ' WHERE id = '1'';

With your code:
le="color: #000000"><?php $results = $xoopsDB->query(' SELECT account FROM ' . $xoopsDB->prefix('wmfx_popsettings') . ' WHERE id = '1' ');


Now when I do an echo to see $results, I'm getting this:
le="color: #000000"><?php Resource id #69

Is this correct or am I doing something wrong?

4
Dave_L
Re:Dropdown, query DB not working
  • 2004/10/6 1:01

  • Dave_L

  • XOOPS is my life!

  • Posts: 2277

  • Since: 2003/11/7


That's probably correct. The result of a query is a resource ID.

You could try printing $opt inside the loop:

le="color: #000000"><?php var_dump('opt', $opt);

Login

Donat-O-Meter

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

Latest GitHub Commits