excel from php and MxSql

Topics: User Forum
Nov 26, 2011 at 11:18 AM


I have all the datas in a database and I would like to know if and how I can use PHPExcel? I only should put the data in a row. In normal PHP the code is as follow.


Tanks for yout tipps and helping




$query="select `a`, `b`, `c`, `d` FROM db where deaktiviert ='' order by a";

<table width=\"100%\" cellpadding=\"1\" cellspacing=\"1\" border=\"1\">
 while($row = mysql_fetch_assoc($result))
  { ?>
    <td><?php if(!empty($row['a'])){echo"$row[a]";}else{ echo"&nbsp;";}?></td>
    <td><?php if(!empty($row['b'])){echo"$row[b]";}else{ echo"&nbsp;";}?></td>
    <td><?php if(!empty($row['c'])){echo"$row[c]";}else{ echo"&nbsp;";}?></td>
    <td><?php if(!empty($row['d'])){echo"$row[d]";}else{ echo"&nbsp;";}?></td>
    <?php } ?>

Nov 28, 2011 at 12:31 PM

Look at the samples in the Tests folder, like 01simple.php.

In your while loop, you would basically setCellValue() in place of echoing to table cells.

Dec 6, 2011 at 7:47 AM


That works fine

while($row = mysql_fetch_row($result))
    $col = 'A';
    foreach($row as $cell) {