Jump to content

Recommended Posts

I have the folllowing loop which only displays the last part of the array:

 

$i = 0; // create a varible that will tell us how many items we looped over 
   foreach ($listprint as $key => $value) { 
   $i++; 


     $content2 = "   
  <tr>
      <th>Qty</th>  
   <th>Description</th>                 
   <th>ProductNumber</th>
   <th>Issue</th>

  </tr>

    <tr >
  <td>" . $value['Quantity'] . "</td></a>
  <td>" . $value['Description'] . "</td></a>
                       <td>" . $value['ProductNumber'] . "</td></a>
  <td>" . $value['Issue'] . "</td></a>
 </tr> </table> ";     





  } 

 

 

The array

 

Array ( [0] => Array ( [ReferenceNumber] => 4543/2323/ [CustomerNumber] => CHU15 [CustomerName] => AngeloJoseph [Description] => Tewksbury [ProductNumber] => 2323/3232 [Quantity] => 5 [issue] => Holes in lining ) [1] => Array (

[ReferenceNumber] => 4543/2323/ [CustomerNumber] => CHU15 [CustomerName] => AngeloJoseph [Description] => Ryder Sahara Boots [ProductNumber] => 34343/232 [Quantity] => 2 [issue] => Ripped Lining ) [2] => Array (

[ReferenceNumber] => 4543/2323/ [CustomerNumber] => CHU15 [CustomerName] => AngeloJoseph [Description] => Oxford Brogues [ProductNumber] => 23232/323 [Quantity] => 1 [issue] => Broken Last ) )

by using $content = you are overwriting the $content variable each time you run through the loop, thus you will only get the last result. do something like

foreach(......){
if(!isset($content)){
 $content = "your string here";
}
else{
 $content .= "your string here";
}

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.