Domanda

Ho una funzione foreach che raggruppa una serie di prodotti, in array separati a seconda del "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);
?>

Ora ho bisogno di prendere SplitProductSarray [] e confrontare ogni gruppo di "DSID" con un altro tavolo con le e -mail di drop ship:

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

Come posso assegnare un'e -mail specifica a un singolo gruppo di prodotti con lo stesso DSID? Qualsiasi aiuto è apprezzato!

È stato utile?

Soluzione

Bel foreach;)

Prova questo:

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

Altri suggerimenti

Penso che tu voglia

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

"select email from " . TABLE_DROP_SHIPPERS . " where id IN =($all_ids)"
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top