我正在尝试比较两个数组。这两个数组都包含一个托运人的 ID。我需要比较这两个数组,每次找到一个匹配的时候,都需要执行一个sql查询来拉出对应id的email。这是我当前的代码:
$orderid = mysql_query("SELECT MAX(orders_id) FROM orders") or die(mysql_error());
$orderid = mysql_fetch_row($orderid);
$purchasedProductId = mysql_query('SELECT products_id FROM orders_products WHERE orders_id = "' . $orderid[0] . '"');
$DSID = mysql_query("SELECT id FROM drop_shippers");
$DSIDarray = Array();
while ($row = mysql_fetch_array($purchasedProductId, MYSQL_ASSOC)) {
$purchasedProductIdarray[] = $row['products_id'];
}
while ($row = mysql_fetch_array($DSID, MYSQL_ASSOC)) {
$DSIDarray[] = $row['id'];
}
//compare $purchasedProductIdarray[] to $DSIDarray[], then save the comparason in the same order as $purchasedProductIdarray[]
对此的任何帮助将不胜感激。另外,如果您知道实现此目的的更好方法,请告诉我!