skip to Main Content

I have a foreach function which groups an array of products, into seperate arrays depending on the ‘dsid’:

$products_array = array();
$products_query = tep_db_query("select products_id, products_name, drop_ship_id from " . TABLE_ORDERS_PRODUCTS . " where orders_id = '" . (int)$orders['orders_id'] . "' order by products_name");
while ($products = tep_db_fetch_array($products_query)) {
  $products_array[] = array('id' => $products['products_id'],
                            'text' => $products['products_name'],
            'dsid' => $products['drop_ship_id'],);
}

<?php
 $products = array();

  foreach($products_array as $current) {
    $dsid = $current['dsid'];
     $products[$dsid][] = $current; 
  }

 $splitproductsarray = array_values($products);
?>

Now I need to take splitproductsarray[] and compare each group of “dsid”‘s to another table with the drop ship emails:

"select email from " . TABLE_DROP_SHIPPERS . " where id = splitproductsarray[]"

How can I assign a specific email to an individual group of products with the same dsid? Any help is appreciated!

2

Answers


  1. Nice foreach 😉

    Try this:

    foreach($splitproductsarray as $dsid => $values) {
        $sql = "select email from " . TABLE_DROP_SHIPPERS . " where id = " . $dsid . " LIMIT 1";
        // do your query
    }
    
    Login or Signup to reply.
  2. i think you want

    $all_ids=implode(',', $splitproductsarray);
    
    "select email from " . TABLE_DROP_SHIPPERS . " where id IN =($all_ids)"
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search