Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

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++;
}
share|improve this question
 
1. var_dump 2. foreach –  zerkms 14 hours ago
 
Took me a little while, but I solved the issue with two foreach functions. Thanks a bunch! –  Jack Sniper 12 hours ago

1 Answer

$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']);
      }

}
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.