Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8837423
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T09:43:12+00:00 2026-06-14T09:43:12+00:00

I have a Product master in which I have 2 fields, ONE is for

  • 0

I have a Product master in which I have 2 fields, ONE is for Main Product (Field name ‘Under’) and SECOND is for Sub-product (Field name is ‘Prod_desc)
What I want is a nested loop where I capture all codes (field name is Cylno) from transaction Table (ECR_CBDC).

I have 2 nested loops, First while loop is for PRODUCT_MASTER where based on user selection of a Main-product the sub-products are selected and SECOND loop is for collecting the codes for all sub-products.

Now the issue is it collects only 1 value as the FOR loop overwrites the previous value. Is there any other loop which can hold the previous value of each sub-product.

$p=mysql_query("SELECT * FROM PRODMAST WHERE Under='$product'");
while ($p2=mysql_fetch_assoc($p))
{
    $prodesc=$p2['Prod_desc'];

    $dc=mysql_query("SELECT * FROM ECR_CBDC WHERE Prod_desc='$prodesc'  AND usr='$user'");
    $num_rows = mysql_num_rows($dc);
    $fill_from_array = array(); /* as "value"=>"option" */
    for($i = 1; $i <= $num_rows; $i++)
    {
        $row = mysql_fetch_assoc($dc);
        $fill_from_array[$row['Cylno']] = $row['Cylno'];
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T09:43:14+00:00Added an answer on June 14, 2026 at 9:43 am

    If I understand what you’re asking – $fill_from_array only collects one row’s worth – I think you need to define $fill_from_array outside of the first loop, so…

    $p=mysql_query("SELECT * FROM PRODMAST WHERE Under='$product'");
    $fill_from_array = array(); /* as "value"=>"option" */
    while ($p2=mysql_fetch_assoc($p))
    {
        $prodesc=$p2['Prod_desc'];
    
        $dc=mysql_query("SELECT * FROM ECR_CBDC WHERE Prod_desc='$prodesc'  AND usr='$user'");
        $num_rows = mysql_num_rows($dc);
        for($i = 1; $i <= $num_rows; $i++)
        {
            $row = mysql_fetch_assoc($dc);
            $fill_from_array[$row['Cylno']] = $row['Cylno'];
        }
    }
    

    That way it’s not over-writing $fill_from_array each time the while() loop loops. Is that what you mean?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a field 'Description' which can have product descriptions with any unicode characters.
I have the following problem: We have a large product which is in master
I have a two tables as follows: product category(t1): id name product master(t2): id
I have a main MySQL table which holds products. Any multiple fields for each
I have a repository named master which keeps product releases. It has several tags
Table one: products Which have fields like products_id products_price master_categories_id Table two: specials .
I have a Category table which has 3 fields i'm interested in: ID, Name,
In a Master page, I have this.... <ul id=productList> <li id=product_a class=active> <a href=>Product
I have a product listing, in which the title of the product is written.
I have a Product Service. On each call to Service, I want to call

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.