Jump to content

Recommended Posts

Hi guys, I need help figuring out what is not working with my code. I use and mysql query to get manufacturers_id (see bellow code)

//CODE

$manufacturer_enum = tep_db_query("select manufacturers_id from products where products_id = '" . (int)$products[$o]['id'] . "'");

$manufacturer_enum_results = mysql_fetch_assoc($manufacturer_enum)

//CODE

 

When I do a printf of $manufacturer_enum_results and I get this (two results)

//RESULTS

Array ( [10] => 1 ) Array ( [11] => 1 )

//RESULTS

 

To see if it's okay I used printf to count the array

//CODE

print_r(count($manufacturer_enum_results));

//

 

But I get "11" as a result ... which from my point of view doesn't make any sense.

 

I really would appreciate a hand on this.

 

Thanks

 

Franck

what is tep_db_query() function

 

  function tep_db_query($query, $link = 'db_link') {

    global $$link;

 

    if (defined('STORE_DB_TRANSACTIONS') && (STORE_DB_TRANSACTIONS == 'true')) {

      error_log('QUERY ' . $query . "\n", 3, STORE_PAGE_PARSE_TIME_LOG);

    }

 

    $result = mysql_query($query, $$link) or tep_db_error($query, mysql_errno(), mysql_error());

 

    if (defined('STORE_DB_TRANSACTIONS') && (STORE_DB_TRANSACTIONS == 'true')) {

      $result_error = mysql_error();

      error_log('RESULT ' . $result . ' ' . $result_error . "\n", 3, STORE_PAGE_PARSE_TIME_LOG);

    }

 

    return $result;

  }

 

Why mysql returns results, it returns the columns in an array, so I would assume that it is returning how many columns it found.

 

If you would like to see how many rows it returned, use: mysql_num_rows

 

mysql_num_rows give me the same "11" as result ...maybe I'm not using it right ... here is complet code portion

 

$manufacturer_enum = tep_db_query_query("select manufacturers_id from products where products_id = '" . (int)$products[$o]['id'] . "'");

$manufacturer_enum_results = mysql_fetch_assoc($manufacturer_enum);

$manufacturer_unique = array_unique($manufacturer_enum_results);

print_r(count(mysql_num_rows($manufacturer_enum)));

 

As you can see what I am trying to do is sort get every manufacturer form the product list. I need to see only unique Manufacturers so they are not duplicated in the list. After that I need to count how many different manufacturers they're is.

 

Hope this can shed some light on what I am trying to do.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.