Help with Loops

Topics: Developer Forum, Project Management Forum, User Forum
Jan 2, 2013 at 4:27 PM

Hi there,

I have recently downloaded and installed this PHPExcel package which I have found to be rather amazing for what I needed, more specifically grabbing images from our database.

I was wondering if it would be possible to help me with loops, I currently found a way to do looping straight from Mysql, but the file I am going to use has some layout properties.

E.g. each mysql row would be 5 cells high and 5 cells wide.

So when the first loop is shown e.g. A1 - A5 i'de like the next loop to skip and do A7 - A12 if this makes sense?

This is the basic code for the looping area:

while($row = mysql_fetch_array($result))

//Draw Image
// Create new picture object
  $objDrawing = new PHPExcel_Worksheet_Drawing();

// Inserting the picture
// Style cell
// Border Colour
$styleArray = array(
       'borders' => array(
             'outline' => array(
                    'style' => PHPExcel_Style_Border::BORDER_THICK,
                    'color' => array('argb' => '000000'),

// Add some data
        ->setCellValue('A1', 'Photo Of Product')
        ->setCellValue('D1', 'Product Name')
	->setCellValue('E1', $row['name'])
        ->setCellValue('D2', 'Brand')
	->setCellValue('E2', 'Adidas')
        ->setCellValue('D3', 'Unit Cost')
	->setCellValue('E3', $row['price'])
	->setCellValue('D4', 'RRP')
	->setCellValue('E4', '�200')
	->setCellValue('F1', 'SIZE BREAKDOWN');


for ($i=0;$i<200;$i++) {



Note: I am aware some of the cell values arent in the MYSQL format, im only dealing with name and price while I get this working.

Effectively I would like to +6 rows on the colum names.


Thank you for reading

Kind Regards

Adam Kernig

Jan 6, 2013 at 12:50 PM

Please end this topic.