Results 1 to 4 of 4

Thread: Problem related to While Loop

  1. #1
    Join Date
    Apr 2012
    Posts
    8
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Problem related to While Loop

    Hi all
    I am not sure how to do this with php.

    I have two queries
    Code:
    $qry = "select * from product where productid='".$dlist."'";
    		
    		$result=mysql_query($qry);
    		
    		
    		$subprodqry = "select * from subproducts where productid='".$dlist."'";
    		
    		$subprod=mysql_query($subprodqry);
    i am writting while loop

    Code:
    while($row = mysql_fetch_array($result) and $subprods = mysql_fetch_array($subprod))
    {	
    
    }
    within the while loop there is a point where i have to assign the values from 2nd array $subprods.

    But the thing is while doing that i have three different records (product names), which i need to assign to 3 different product images. when i do that i get three different results
    how can i do that do have to write another while loop for assigning the values. I am giving the code where i have to write it....
    Code:
    <td align="left" valign="middle" bgcolor="#4E8EB4" >';
    					  echo "&nbsp;Product Name :-- '". $subprods["subPartName"]."'</td>";
    					  echo '
    					  <td rowspan="4" valign="top" bgcolor="#FFFFCC" ><!--DWLayoutEmptyCell-->&nbsp;</td>
    					  <td align="left" valign="middle" bgcolor="#4E8EB4" >';
    					  echo "&nbsp;Product Name :--'". $subprods["subPartName"]."'<!--DWLayoutEmptyCell-->&nbsp;</td>";
    					  echo '
    					  <td rowspan="4" valign="top" bgcolor="#FFFFCC" ><!--DWLayoutEmptyCell-->&nbsp;</td>
    					  <td align="left" valign="middle" bgcolor="#333333" >';
    					  echo "&nbsp;Product Name :-->'". $subprods["subPartName"]."'<!--DWLayoutEmptyCell-->&nbsp;</td>";
    					  echo '
    					  <td >
    i want to put the sub product name from the $subprods array ,every image has its name so it will be assigned uniquely....how can i do that....same after the image is displayed and below that is the product code same way while loop and every product has product code which need to be displayed.
    Thanks in Advance....
    Help need is urgent...for my customer web site..

  2. #2
    Join Date
    Apr 2012
    Posts
    8
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Problem related to While Loop(Problem Resolved)

    Hi Just to give information, i have resolved the problem.
    I took three loops for three different fields and within the while loop i put another loop and took the records from $subprods into each array and i assigned the array value to product name and product code the code is as below


    Code:
    while($row = mysql_fetch_array($result) )
    		{	
    				//session_destroy();
    				while ($subprods = mysql_fetch_array($subprod))
    				{
    					$subarray[]=$subprods["subPartName"];
    					$subpcode[]=$subprods["subPartId"];
    					$subdesc[]=$subprods["subProdDesc"];
    				}
    
    }
    I took three arrays like above and following code gives idea about how i use that array for assigning the values.
    Code:
    <td align="left" valign="middle" bgcolor="#4E8EB4" >';
    					  echo "&nbsp;Product Name :-- '". $subarray[0]."'</td>";
    					  echo '
    					  <td rowspan="4" valign="top" bgcolor="#FFFFCC" ><!--DWLayoutEmptyCell-->&nbsp;</td>
    					  <td align="left" valign="middle" bgcolor="#4E8EB4" >';
    					  echo "&nbsp;Product Name :--'". $subarray[1]."'<!--DWLayoutEmptyCell-->&nbsp;</td>";
    					  echo '
    					  <td rowspan="4" valign="top" bgcolor="#FFFFCC" ><!--DWLayoutEmptyCell-->&nbsp;</td>
    					  <td align="left" valign="middle" bgcolor="#333333" >';
    					  echo "&nbsp;Product Name :-->'". $subarray[2]."'<!--DWLayoutEmptyCell-->&nbsp;</td>";
    					  echo '
    					  <td >
    Hope this info will be help full to someone...

  3. #3
    Join Date
    Apr 2012
    Posts
    8
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    Hi Admin This thread can be closed as the problem is resolved.. Please let me know how to make it solved or i request you to please make it solved and close the thread
    Thanking you.

  4. #4
    Join Date
    Mar 2011
    Location
    N 11 19' 0.0012 E 142 15' 0
    Posts
    1,531
    Thanks
    41
    Thanked 89 Times in 88 Posts
    Blog Entries
    3

    Default

    If this thread is finished, please set it to resolved.
    You can do this by editing the first post within the thread - Pressing go advanced - then where it says no prefix, selecting resolved then save.


    That's how you set the thread to resolved. DDadmin (and Moderators?) can close the thread.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •