Page 1 of 2 12 LastLast
Results 1 to 10 of 12
  1. #1
    Join Date
    Jul 2012
    Posts
    45
    Plugin Contributions
    0

    Default Question with zen_draw_pull_down_menu

    Good afternoon:

    I am in process of customizing my 1.50 installation on GoDaddy for my organization. We have approximately 2500 end-users that will be transitioning from a paper and telephone to electronic supply ordering processes realistically through 2Q and 3Q 2013. ZenCart will be serving as our primary web-front between two separate installations. We are presently in a beta environment while working out the bugs and are working some things out. One of the things we have found is that our end users want point and click functionality when selecting their particular duty stations rather than typing them in (we have over fifty separate locations). To that end, I am using MySQL to automatically populate a dropbox created using zen_draw_pull_down automatically on the fly.

    I am having some difficulty accomplishing this. My dropbox will detect the five test rows, it will not populate the data in these rows, however. Code and links are attached. Any help anyone can give would be appreciated.

    Regards,

    Jeremiah Cook
    Inventory Systems Specialist
    Indianapolis EMS

    http://www.iemssupply.org/zencart/in...ain_page=login

    Code:
    $IEMSquery = "SELECT * from `thedatabase`.`thedatatable`";
          	
    $result = mysql_query($IEMSquery) or die(mysql_error());
    	
    $unit = array();
          
    while($row = mysql_fetch_array($result)){
    	
    	$unit[$row['friendly_name']] = $row ['friendly_name'];};
    
    print_r($unit); 
    
    echo zen_draw_pull_down_menu('suburb',$unit,'','');

  2. #2
    Join Date
    Sep 2009
    Location
    Stuart, FL
    Posts
    12,399
    Plugin Contributions
    87

    Default Re: Question with zen_draw_pull_down_menu

    The second parameter to zen_draw_pull_down_menu is an associative array of the form
    Code:
    $optionArray = array ( array ( 'id' => 'ID1', 'text' => 'text1'), array ('id' => 'ID2', 'text' => 'text2') );
    where the 'id' elements define the value returned if that option is selected and the 'text' elements define the value displayed for that option. You can have as many 'id'/'text' pairs as you need.

  3. #3
    Join Date
    Jul 2012
    Posts
    45
    Plugin Contributions
    0

    Default Re: Question with zen_draw_pull_down_menu

    No.

    That's not what I'm looking for.

    I can't hardcode the associative array into the module. It has to be driven by MySQL. Sorry.

  4. #4
    Join Date
    Jul 2012
    Posts
    45
    Plugin Contributions
    0

    Default Re: Question with zen_draw_pull_down_menu

    I may have answered my own question folks, and you may have led me to my answer...I will let you all know what I came up with :-)

  5. #5
    Join Date
    Jul 2012
    Posts
    45
    Plugin Contributions
    0

    Default Re: Question with zen_draw_pull_down_menu

    It was a circular reference within my code. I was trying to get something to work and the code was cancelling itself out.

  6. #6
    Join Date
    Jul 2012
    Posts
    45
    Plugin Contributions
    0

    Default Re: Question with zen_draw_pull_down_menu

    Code:
    //set us up a query to pull all data from our data table
    $IEMSquery = "SELECT * from `thedatabase`.`thedatatable`";
    //run that query     	
    $result = mysql_query($IEMSquery) or die(mysql_error());
    //dump that query into an array	
    $unit = array();
    //while that result exists      
    while($row = mysql_fetch_array($result)){
    //dump the results row by row into the array where the ID number and friendly name match up	
    	$unit[$row['id']] = $row ['friendly_name'];};
    //and then echo the pull down menu line, call it suburb, and use the unit variable to pass that function its values
    echo zen_draw_pull_down_menu('suburb',$unit,'','style="width: 20em;"');
    //EOF

  7. #7
    Join Date
    Jul 2012
    Posts
    45
    Plugin Contributions
    0

    Default Re: Question with zen_draw_pull_down_menu

    Now I have the first letter issue that the other gentleman was having a few years back. I still cannot hard code this in, so I am investigating how to correct that issue.

  8. #8
    Join Date
    Jul 2012
    Posts
    45
    Plugin Contributions
    0

    Default Re: Question with zen_draw_pull_down_menu

    Here's where I am at:

    Hard coding is a last resort. An extreme, last resort. I have at least seventy different unique lines that this dropbox needs to hold and that will be subject to change. I do not have the time or the freedom to take this system offline every time that I need to add a unit or make a change to the dropbox. I really need this functionality before I roll to production, folks. If anyone has any inkling of any idea of how I can make this work without hard coding, I would appreciate your input. Again, I CANNOT hardcode this into the module - it must be dynamically populated using a query on the fly from the database, not hardcoded.

    I thank you in advance.

  9. #9
    Join Date
    Sep 2009
    Location
    Stuart, FL
    Posts
    12,399
    Plugin Contributions
    87

    Default Re: Question with zen_draw_pull_down_menu

    I wasn't suggesting that you hard-code the array, only showing you the array structure expected by zen_draw_pull_down_menu function's second parameter. Try making the changes in red:

    Code:
    //set us up a query to pull all data from our data table
    $IEMSquery = "SELECT * from `thedatabase`.`thedatatable`";
    //run that query     	
    $result = mysql_query($IEMSquery) or die(mysql_error());
    //dump that query into an array	
    $unit = array();
    //while that result exists      
    while($row = mysql_fetch_array($result)){
    //dump the results row by row into the array where the ID number and friendly name match up	
        $unit[] = array ( 'id' => $row['id'], 'text' => $row['friendly_name']);
    //	$unit[$row['id']] = $row ['friendly_name'];
    };
    //and then echo the pull down menu line, call it suburb, and use the unit variable to pass that function its values
    echo zen_draw_pull_down_menu('suburb',$unit,'','style="width: 20em;"');
    //EOF

  10. #10
    Join Date
    Jul 2012
    Posts
    45
    Plugin Contributions
    0

    Default Re: Question with zen_draw_pull_down_menu

    No dice. I have a feeling that's down the right track, though.

    I do appreciate your help, nonetheless. One of those niggling little annoying features keeping us from rolling to full deployment, as it were.

 

 
Page 1 of 2 12 LastLast

Similar Threads

  1. zen_draw_pull_down_menu, remember selected value
    By quick1 in forum General Questions
    Replies: 9
    Last Post: 16 May 2011, 02:10 AM
  2. zen_draw_pull_down_menu width
    By adamlonsdale in forum Templates, Stylesheets, Page Layout
    Replies: 1
    Last Post: 4 Jun 2010, 06:03 PM
  3. Replies: 2
    Last Post: 13 Jan 2010, 01:37 PM
  4. help with zen_draw_pull_down_menu function
    By keithstric in forum Templates, Stylesheets, Page Layout
    Replies: 3
    Last Post: 4 Aug 2009, 09:17 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
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR