【问题标题】:assigning email to group of arrays将电子邮件分配给数组组
【发布时间】:2013-11-06 22:48:20
【问题描述】:

我有一个 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 的单个产品组?任何帮助表示赞赏!

【问题讨论】:

    标签: php mysql arrays mysqli oscommerce


    【解决方案1】:

    很好的 foreach ;)

    试试这个:

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

    【讨论】:

    • 感谢scrowler!你帮了大忙。
    【解决方案2】:

    我想你想要

    $all_ids=implode(',', $splitproductsarray);
    
    "select email from " . TABLE_DROP_SHIPPERS . " where id IN =($all_ids)"
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-10-20
      • 2021-05-12
      • 2016-03-01
      • 2015-07-18
      • 2017-08-16
      • 1970-01-01
      • 2018-09-26
      相关资源
      最近更新 更多