I have a bit of PHP code that's baffling me for some reason. I know that I need to iterate through the array and run a SQL query for each value in the array, but I'm getting lost of how to do that in my code:
$kit_bin_count = 0;
$kit_itemno_array = null;
$kit_bin_array = null;
// iterate through array
while ($kit_row = odbc_fetch_array($result_ickitd)) {
// store results from mysql in our own PHP array
$kit_itemno_array[$kit_count] = $kit_row['COMPONENT'];
// increment counter
$kit_count++;
}
for($k=0;$k<sizeof($kit_itemno_array);$k++) {
$var_kit_item = $kit_itemno_array[$k];
$newvar_kit_item = trim($var_kit_item);
}
/* $params = "'".implode("','",$kit_itemno_array)."'";
echo "$params"; */
/* foreach ($kit_itemno_array as $country)
{
$query .= "OR stv.name = '{$country}', ";
} */
$sql_kit_bin="SELECT * FROM icitem, iciloc WHERE icitem.itemno = '$kit_itemno_array[$k]' AND iciloc.itemno = icitem.itemno";
$result_kit_bin=odbc_exec($conn,$sql_kit_bin);
while ($kit_bin_row = odbc_fetch_array($result_kit_bin)) {
$kit_bin_array[$kit_bin_count] = $kit_bin_row['PICKINGSEQ'];
$kit_bin_count++;
print_r($kit_bin_array);
}
// END KITTING
echo "<span style=\"color:#66CCFF\">";
echo "$kit_bin_array[$k]";
foreach ($kit_bin_array as $kit_bin) {
// if(strpos($file_array, $kit_item ) !== FALSE) {
echo '<br />' . $kit_bin ; }
// else {
// $kit_post_array[] = $kit_item;
// echo '<br />' . 'KI: ' . $kit_item ; }
// }
echo "</span>";
My code is returning the first value correctly and placing it in the $kit_item_array variable, but additional rows are getting lost. I'm unsure of how to loop this inside of my existing loop so everything is returned properly.
Here is a screenshot of the results, including a print_r() of the arrays being returned.

$kit_countis used...take it out and I get no results. I will admit that$kit_bin_countwas useless and was probably left there after trying several scenarios out. Regardless, does anyone have an idea of how I can get this to work?