I am trying to search a sql database for a model number, that is a value from another array ($l3) and return the product_id. The key2[] sample output looks like this
[0] => Array
(
[0] => 359
[products_id] => 359
[1] => PD124
[products_model] => PD124
)
[1] => Array
(
[0] => 606
[products_id] => 606
[1] => AA214
[products_model] => AA214
)
$products = mysql_query("SELECT products_id, products_model FROM products") or die(mysql_error());
while($info = mysql_fetch_array($products))
{
$key2[] = $info;
}
for ($i = count($options_values) ; $i != 0; $i--)
{
if ($a1[$i] != "")
{
$l = array($a1[$i]);
foreach ($l as $l)
{
$c1 = $id;
$formatted = array($key[$i], 'Radio','','',$l,'','');
fputcsv($out, $formatted, chr(9));
$id++;
}
}
if ($a2[$i] != "")
{
$l2 = array($a2[$i]);
foreach ($l2 as $l2)
{
$c2 = $id2;
$formatted2 = array($c2, $key[$i], $l2, '');
fputcsv($out2, $formatted2, chr(9));
$id2++;
}
$l3 = array($a3[$i]);
foreach ($l3 as $l3)
{
$c3 = $id3;
$prodid = array_search($l3, $key2);
$formatted3 = array($c3, $key[$i],$l3, $prodid ); //Everything works, but the $prodid is not giving me the answer I want.
fputcsv($out3, $formatted3, chr(9));
$id3++;
}
}
}