ShaGGy Posted January 15, 2012 Posted January 15, 2012 Can anyone see why the code below is returning an empty drop down box? I have ran the query separately and it finds the results but the html_output part does not appear to be getting the values from the query. (this is a modified Countries selection box from within create_account.php) general.php function tep_get_businesses($businesses_id = '') { $businesses_array = array(); if (tep_not_null($businesses_id)) { $businesses = tep_db_query("select business_id, business from " . TABLE_BUS_TYPE . " where active = 1 order by business"); } return $businesses_array; } general.php function tep_get_business_name($business_id) { $business_array = tep_get_businesses($business_id); return $business_array['business']; } html_output.php function tep_get_business_list($name, $selected = '', $parameters = '') { $businesses_array = array(array('id' => '', 'text' => PULL_DOWN_DEFAULT)); $businesses = tep_get_businesses(); for ($i=0, $n=sizeof($businesses); $i<$n; $i++) { $businesses_array[] = array('id' => $businesses[$i]['business_id'], 'text' => $businesses[$i]['business']); } return tep_draw_pull_down_menu($name, $businesses_array, $selected, $parameters); } create_account.php <tr> <td class="fieldKey"><?php echo ENTRY_BUS_TYPE; ?></td> <td class="fieldValue"><?php echo tep_get_business_list('business') . ' ' . (tep_not_null(ENTRY_BUS_TYPE_TEXT) ? '<span class="inputRequirement">' . ENTRY_BUS_TYPE_TEXT . '</span>': ''); ?></td> </tr>
♥kymation Posted January 15, 2012 Posted January 15, 2012 The problem is here: $businesses = tep_get_businesses(); tep_get_businesses() returns an empty array if you don't specify an ID. Since that array size is zero, the pulldown array will also be empty. You need to modify the tep_get_businesses() function to return the entire list if the ID is null. Regards Jim See my profile for a list of my addons and ways to get support.
ShaGGy Posted January 15, 2012 Author Posted January 15, 2012 The problem is here: $businesses = tep_get_businesses(); tep_get_businesses() returns an empty array if you don't specify an ID. Since that array size is zero, the pulldown array will also be empty. You need to modify the tep_get_businesses() function to return the entire list if the ID is null. Regards Jim Thanks mangaged to fix it i was over velous trimming out the else commands. all working now
Recommended Posts
Archived
This topic is now archived and is closed to further replies.