Subject:*
<
Name/Email:*
<
Message Icon:*
<
Select*
<
Message:*
<



Click the Preview to see the content in action.
Options:*
<
Confirmation Code*
<
9 - 1 = ?  
Input the result from the expression
Maximum attempts you can try: 10
*
<
   

Re: Dropdown select problem with xoopsForm classes
by urbanspacema on 2008/5/23 9:16:42

work !!!!!!!!
thank you very much

there is only a small error in the code

le="color: #000000"><?php $result3 = $xoopsDB->query( "SELECT * FROM ".$xoopsDB->prefix("umus_format")."" ) ; while ($myrow = $xoopsDB->fetchArray($result)) { $formats[$myrow['format_id']] = $myrow['format_title'];


modify
with this

while ($myrow = $xoopsDB->fetchArray($result3)){


tnx Trabis
Urban
Re: Dropdown select problem with xoopsForm classes
by trabis on 2008/5/21 19:01:51

Hi, did not tested but, try this:
le="color: #000000"><?php // Controllo se esistono i formati altrimenti non posso creare una recensione e vengo rimandato alla pagina dei formati $result2 = $xoopsDB->query( "SELECT count(format_id) as count FROM ".$xoopsDB->prefix("umus_format")."" ) ; list( $count ) = $xoopsDB->fetchRow( $result2 ) ; if( $count < 1 ) { redirect_header(XOOPS_URL."/modules/umusic/admin/admin_format.php",2,_MI_UMUS_MUSTADDFORMATFIRST); exit(); } $formats = array(); $result3 = $xoopsDB->query( "SELECT * FROM ".$xoopsDB->prefix("umus_format")."" ) ; while ($myrow = $xoopsDB->fetchArray($result)) { $formats[$myrow['format_id']] = $myrow['format_title']; } // Creo la select per mostrare i formati $format_select = new XoopsFormSelect(_MI_UMUS_REV_SELECTFORMAT, "format_id"); $format_select->addOptionArray( $formats ) ; // $my_form->addElement( $format_select ) ;


You cannot use tree because you do not have a tree structure on your table. For using that class you must have Id and parent Id. You have a single id so... no tree for you!
Re: Dropdown select problem with xoopsForm classes
by urbanspacema on 2008/5/21 11:06:09

thank you catzwolf_

I'm trying to understand how XoopsObjectTree works

with this code

le="color: #000000"><?php $umus_categories = $xoopsDB->prefix( 'umus_categories' ) ; $cat_tree = new XoopsObjectTree($umus_categories, 'category_id', 'category_title'); $cat = $cat_tree->makeSelBox('category_id', 'category_title', '-- ', $category_id, true);


I see only a empty select box...

debug show this error
Warning: array_keys() [function.array-keys]: The first argument should be an array in file /class/tree.php line 79

you could help me please?

Urban
Re: Dropdown select problem with xoopsForm classes
by Catzwolf on 2008/5/20 22:33:44

Did you check to see if your $treef array has the proper array structure that you want? It looks like $leaff['format_id'] && $leaff['prefix'] . $leaff['format_title'] have been swapped around?

Plus don't use xoopstree, it is a resource hog and will be removed from XOOPS at one point. I would suggest that you look into xoopsObject and use the tree.php class instead with it.
Dropdown select problem with xoopsForm classes
by urbanspacema on 2008/5/20 15:31:48

Hello to all
First, I apologize for my English certainly terrible!!

Here's my problem

I am carrying out a form with XOOPS classes for a new module

I have create a SELECT menu (drop down) which takes data from a table.

Table called umus_format and his 2 fields format_id and format_title

drop down displays all values but not showing the values that begin with a number...

ex. CD,DVD,LP are ok 2CD,2DVD,2LP do not appear

Here is the code.

le="color: #000000"><?php // Controllo se esistono i formati altrimenti non posso creare una recensione e vengo rimandato alla pagina dei formati $result2 = $xoopsDB->query( "SELECT count(format_id) as count FROM ".$xoopsDB->prefix("umus_format")."" ) ; list( $count ) = $xoopsDB->fetchRow( $result2 ) ; if( $count < 1 ) { redirect_header(XOOPS_URL."/modules/umusic/admin/admin_format.php",2,_MI_UMUS_MUSTADDFORMATFIRST); exit(); } $umus_format = $xoopsDB->prefix( "umus_format" ) ; $ftree = new XoopsTree($umus_format,"format_id", "format_title" ) ; // Creo la select per mostrare i formati $format = new XoopsFormSelect( _MI_UMUS_REV_SELECTFORMAT , "format_id" , $format_id ) ; $treef = $ftree->getChildTreeArray( 0 , "format_id" ) ; foreach( $treef as $leaff ) { $leaff['prefix'] = substr( $leaff['prefix'] , 0 , -1 ) ; $leaff['prefix'] = str_replace( "." , "--" , $leaff['prefix'] ) ; $format->addOption( $leaff['format_id'] , $leaff['prefix'] . $leaff['format_title'] ) ; } // $my_form->addElement( $format ) ;


if I make a normal query to the database I see that all values are inserted correctly

Mysql code

le="color: #000000"><?php CREATE TABLE umus_format ( format_id tinyint(3) unsigned NOT NULL auto_increment, format_title varchar(255) NOT NULL default '', PRIMARY KEY (format_id) ) TYPE=MyISAM; INSERT INTO umus_format (format_title) VALUES ('CD'); INSERT INTO umus_format (format_title) VALUES ('2CD'); INSERT INTO umus_format (format_title) VALUES ('DVD'); INSERT INTO umus_format (format_title) VALUES ('2DVD'); INSERT INTO umus_format (format_title) VALUES ('LP'); INSERT INTO umus_format (format_title) VALUES ('2LP'); INSERT INTO umus_format (format_title) VALUES ('12"'); INSERT INTO umus_format (format_title) VALUES ('10"'); INSERT INTO umus_format (format_title) VALUES ('7"'); INSERT INTO umus_format (format_title) VALUES ('Digital'); INSERT INTO umus_format (format_title) VALUES ('Cassette'); INSERT INTO umus_format (format_title) VALUES ('Altro');



which may be the problem? I have perhaps found a bug?

Urban

Who's Online

171 user(s) are online (131 user(s) are browsing Support Forums)


Members: 0


Guests: 171


more...

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