Forums / General Questions / Question with zen_draw_pull_down_menu

Question with zen_draw_pull_down_menu

Views: 2,176

Results 1 to 12 of 12
30 Nov 2012, 4:50 PM
#1
jrcook416 avatar

jrcook416

New Zenner

Join Date:
Jul 2012
Posts:
45
Plugin Contributions:
0

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/index.php?main_page=login

$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,'','');
30 Nov 2012, 7:09 PM
#2
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,119
Plugin Contributions:
56

Re: Question with zen_draw_pull_down_menu

The second parameter to zen_draw_pull_down_menu is an associative array of the form

$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.

30 Nov 2012, 7:31 PM
#3
jrcook416 avatar

jrcook416

New Zenner

Join Date:
Jul 2012
Posts:
45
Plugin Contributions:
0

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.

30 Nov 2012, 7:45 PM
#4
jrcook416 avatar

jrcook416

New Zenner

Join Date:
Jul 2012
Posts:
45
Plugin Contributions:
0

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 :-)

30 Nov 2012, 7:54 PM
#5
jrcook416 avatar

jrcook416

New Zenner

Join Date:
Jul 2012
Posts:
45
Plugin Contributions:
0

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.

30 Nov 2012, 8:00 PM
#6
jrcook416 avatar

jrcook416

New Zenner

Join Date:
Jul 2012
Posts:
45
Plugin Contributions:
0

Re: Question with zen_draw_pull_down_menu

//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
30 Nov 2012, 8:20 PM
#7
jrcook416 avatar

jrcook416

New Zenner

Join Date:
Jul 2012
Posts:
45
Plugin Contributions:
0

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.

30 Nov 2012, 10:18 PM
#8
jrcook416 avatar

jrcook416

New Zenner

Join Date:
Jul 2012
Posts:
45
Plugin Contributions:
0

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.

1 Dec 2012, 2:15 PM
#9
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,119
Plugin Contributions:
56

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:

//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
1 Dec 2012, 5:38 PM
#10
jrcook416 avatar

jrcook416

New Zenner

Join Date:
Jul 2012
Posts:
45
Plugin Contributions:
0

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.

3 Dec 2012, 1:12 PM
#11
jrcook416 avatar

jrcook416

New Zenner

Join Date:
Jul 2012
Posts:
45
Plugin Contributions:
0

Re: Question with zen_draw_pull_down_menu

Unfortunately, the development deadline for this milestone has passed. We will have to move forward with hard-coding the functionality into the module as a last-resort workaround as I had hoped not to do.

Thank you to lat9 for your assistance in trying to help to clear up our problem.

If anyone else has any ideas, please feel free to post to this thread. If relevant, we are using GoDaddy as a hosting solution provider and version 1.50 as our codebase.

4 Dec 2012, 1:33 PM
#12
jrcook416 avatar

jrcook416

New Zenner

Join Date:
Jul 2012
Posts:
45
Plugin Contributions:
0

Re: Question with zen_draw_pull_down_menu

Update:

There will be a way around this in the long run.

My plan is to write my own function as a lookup in my own roadmap down the road.

On a brighter note, I did write in some functionality which I will share with the group at a later time.

Much thanks to everyone for making a great product and I look forward to contributing in the future.

Regards,

Jeremiah Cook
Inventory System Specialist
Indianapolis EMS