Jump to content


Corporate Sponsors


Latest News: (loading..)

- - - - -

Why is this not finding the results from the table ?


2 replies to this topic

#1 ShaGGy

  • Community Member
  • 59 posts
  • Real Name:Les

Posted 15 January 2012, 02:54

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') . '&nbsp;' . (tep_not_null(ENTRY_BUS_TYPE_TEXT) ? '<span class="inputRequirement">' . ENTRY_BUS_TYPE_TEXT . '</span>': ''); ?></td>
	  </tr>


#2 kymation

  • Community Sponsor
  • 5,663 posts
  • Real Name:Jim Keebaugh
  • Gender:Male
  • Location:Aberdeen WA USA

Posted 15 January 2012, 03:53

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

Edited by kymation, 15 January 2012, 03:54.

My Addons

Banners Box 2.3.1 Support
Categories Accordion Box 2.3.1 Support
Categories Images Box 2.2x 2.3.1 Support
Closest Shipper 2.2x Support
Document Manager 2.2x Support
Generic Box 2.3.1 Support
Get 1 Free 2.2x Support
Include HTML and Text Boxes 2.2x
jQuery Banner Rotator 2.2x 2.3.1 Support
Modular Front Page 2.3.1 Support
Modular SEO Header Tags 2.3.1 Support
More Pics 2.2x Support
MVS 2.2x Support
osC Catalog 2.2x Support
PDF Datasheet 2.3.1 Support
Price Updater 2.2x
Products Specifications 2.2x 2.3.1 Development Version Support Bugs/Suggestions
Request a Review 2.2x - 2.3.1 Support
Similar Products Box 2.2x
Theme Switcher 2.3.1 Support

#3 ShaGGy

  • Community Member
  • 59 posts
  • Real Name:Les

Posted 15 January 2012, 17:02

View Postkymation, on 15 January 2012, 03:53, said:

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