Building a custom mod that I plan on releasing later this month. Basically, I need to do the following 6 times. I know that repeating this code 6 times with different variables is wrong. I'm just not sure how to proceed. I apologize in advance for my noobness.
$sql = "SELECT products_quantity
FROM " . TABLE_PRODUCTS . "
WHERE products_id='" . (int)$p_id_1 . "'";
$p_stock = $db->Execute($sql);
$item_1_stock = $p_stock->fields['products_quantity'];
So let's say I start wtih this array :
$_product_id_array = array ($p_id_1, $p_id_2, $p_id_3, $p_id_4, $p_id_5, $p_id_6);
I need an array that would output these keys and values:
item_stock_array(6) {
["product_id_1"]=>
int($item_1_stock) // <-- Actual value from the query above, not the variable $item_1_stock
["product_id_2] => // and so on for all 6 values
...
}


Reply With Quote
