Page 1 of 4 1234 LastLast
Results 1 to 10 of 32

Thread: Link dropdown - db table

  1. #1
    DragonflyMaster is offline Sugar Community Member
    Join Date
    Dec 2007
    Location
    Rimini, Italy
    Posts
    1,421

    Default Link dropdown - db table

    Hi everybody,

    I'd like to link a dropdown field to a db table, in order to make it show the values inside that table and not in a php file.
    I'm not quite sure: how to create the logic for this control?
    Any idea?


    Sugar 5.0.0a CE - MSWindows2003Server - IIS 6 - PHP 5 - MSSQL 2005
    Last edited by DragonflyMaster; 2008-02-21 at 03:00 PM.
    What do you think the cookie monster eats ?

  2. #2
    jli
    jli is offline Junior Member
    Join Date
    May 2005
    Posts
    109

    Default Re: Link dropdown - db table

    you cannot do this without custom coding; you can essentially make SQL calls to override and populate the key/value pairs of a pre-created drop down

  3. #3
    DragonflyMaster is offline Sugar Community Member
    Join Date
    Dec 2007
    Location
    Rimini, Italy
    Posts
    1,421

    Default Re: Link dropdown - db table

    Thanks for replying.
    I know it's a thing that requires custom coding, what I'm not sure about is where to place the custom code.
    Not long ago I managed to link two dropdowns using javascript, but now I'd like to go further, making these dropdown show values from db tables.
    In particular, opening dropdown A I'll see values in TABLE_A.Field1; after the choice, in dropdown B I'll have certain values, depending on the choice made in dropdown A.
    The second part of the thing is done, I'm just unable to make it read a db table and show it in dropdowns.
    What do you think the cookie monster eats ?

  4. #4
    DragonflyMaster is offline Sugar Community Member
    Join Date
    Dec 2007
    Location
    Rimini, Italy
    Posts
    1,421

    Default Re: Link dropdown - db table

    I haven't been able to solve this issue yet.
    Is there anybody who could help me with it?
    I have a custom db table where I stored data about cities and their zip codes.
    What I'd like to create is a dropdown that shows a list of cities taken from my custom table; when I select a city form this dropdown I'd like to see in a second dropdown the list of zip codes for that city.

    Any suggestion is very welcome, thanks.
    What do you think the cookie monster eats ?

  5. #5
    DragonflyMaster is offline Sugar Community Member
    Join Date
    Dec 2007
    Location
    Rimini, Italy
    Posts
    1,421

    Default Re: Link dropdown - db table

    Ok,

    after a week spent on this, we've finally managed to solve this issue.
    Basically we built a dropdown and made sql query to estract data from a db table.
    What we didn't know was the best place to put our code, now we've found out.
    What do you think the cookie monster eats ?

  6. #6
    caporales is offline Sugar Community Member
    Join Date
    Jan 2008
    Posts
    10

    Default Re: Link dropdown - db table

    You could explain a little more as it has succeeded. Thanks !!! I'm need you help.

  7. #7
    DragonflyMaster is offline Sugar Community Member
    Join Date
    Dec 2007
    Location
    Rimini, Italy
    Posts
    1,421

    Default Re: Link dropdown - db table

    Hi,
    here's the to-do list:
    1. create a dropdown in studio/module builder
    2. write custom code to override dropdown definition
    3. put custom code in the right php file
    In my case, I
    1. created a dropdown to show data from db in Account's editview.
    2. wrote php code to run a simple sql query on a db table:
    Code:
    $myQuery = "select * from my_table";
    $myResult=mssql_query($myQuery);
    while ($myRow = mssql_fetch_array($myResult)) {
    $myArray [] = $myRow['my_table_field'] ;
    }
    $GLOBALS['app_list_strings']['MyDropdown_list']= $myArray
    3. put this custom code in <sugar-root>\custom\include\language\en_us.lang.php
    What do you think the cookie monster eats ?

  8. #8
    caporales is offline Sugar Community Member
    Join Date
    Jan 2008
    Posts
    10

    Default Re: Link dropdown - db table

    Thanks !!!!!!

    One more cuestion....

    As for item and value, ??

    $myQuery = "select PRO_CODIGO, PRO_DESCRIP from PROVINCIAS";
    $myResult=mssql_query($myQuery);
    while ($myRow = mssql_fetch_array($myResult)) {
    $myArray [] = $myRow['PRO_CODIGO'] . ' =>' . $myRow['PRO_DESCRIP] ;
    }
    $GLOBALS['app_list_strings']['Provincias_list']=$myArray

  9. #9
    caporales is offline Sugar Community Member
    Join Date
    Jan 2008
    Posts
    10

    Default Re: Link dropdown - db table

    YESS Succeed !!!

    Very easy !!!!!

    ...
    $myArray [$myRow['PRO_CODIGO']] = $myRow['PRO_DESCRIP'];


    Thanks DragonflyMaster !!!!

  10. #10
    DragonflyMaster is offline Sugar Community Member
    Join Date
    Dec 2007
    Location
    Rimini, Italy
    Posts
    1,421

    Default Re: Link dropdown - db table

    De nada!
    I'm glad if I've helped you.
    What do you think the cookie monster eats ?

Page 1 of 4 1234 LastLast

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Manually drop scheme (5.0 upgrade) ?
    By niallhannon in forum Installation and Upgrade Help
    Replies: 1
    Last Post: 2008-01-07, 05:41 PM
  2. problemi step 6 di SugarSuite-Full-4.0.1h
    By lucia in forum Italiano
    Replies: 0
    Last Post: 2006-12-27, 08:50 AM
  3. Fatal error: Max
    By spokes2k4 in forum Help
    Replies: 3
    Last Post: 2006-01-15, 03:50 PM
  4. php 5.0.4 + MySQL 5.0.9
    By sergiogu in forum Help
    Replies: 0
    Last Post: 2005-08-30, 04:38 PM
  5. Empty config.php at the end of install
    By aemadrid in forum Help
    Replies: 2
    Last Post: 2005-08-01, 06:29 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •