Question

I'm having trouble with a while loop that I'm trying to create within oscommerce. I'm trying to pull the 'secondary_id' from each row that has a product ID within the $products_array[$i]['id'] array, then store the secondary_id's in the $finddsid_query array. I'm trying to perform this function with the oscommerce database functions, but I can't seem to get it to fire. Any help or criticism would be greatly appreciated!

$array_size = count($products_array);
$finddsid_query = tep_db_query("select secondary_id from products where products_id = '" . $products_array[$i]['id'] . "'");
$i = 0;

while ($i <= $array_size - 1) {
    print_r( $finddsid_query[$i] );
    $i++;
}
Was it helpful?

Solution

$finddsid_arrray = array();
  foreach ($products_array as $value) {
    $finddsid_query = tep_db_query("select secondary_id from products where products_id = " . $value['id']);
    $finddsid = tep_db_fetch_array($finddsid_query);
      foreach ($finddsid as $pdsid) {
         $finddsid_arrray[] = array('dsid' => $pdsid['id']);
      }

}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top