我有一个foreach函数,该函数根据'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);
?>


现在,我需要使用splitproductsarray []并将每个“ dsid”组与另一个带有发送电子邮件的表进行比较:

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


如何将特定电子邮件分配给具有相同dsid的单个产品组?任何帮助表示赞赏!

最佳答案

很好foreach;)

尝试这个:

foreach($splitproductsarray as $dsid => $values) {
    $sql = "select email from " . TABLE_DROP_SHIPPERS . " where id = " . $dsid . " LIMIT 1";
    // do your query
}

09-12 12:22