문제

'DSID'에 따라 제품 배열을 분리 된 배열로 그룹화하는 Foreach 함수가 있습니다.

$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
}

다른 팁

나는 당신이 원한다고 생각합니다

$all_ids=implode(',', $splitproductsarray);

"select email from " . TABLE_DROP_SHIPPERS . " where id IN =($all_ids)"
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top