Note that there are some explanatory texts on larger screens.

plurals
  1. POHTML TABLES EXCEL PHP MYSQL
    primarykey
    data
    text
    <p>I am attempting to export mysql data into excel. I have tried the phpexcel class, and cannot use this on my host, as they do not have the zip function installed. I cannot export the data to csv, as the client 'wants to see purty colors...' so formatting is a must. So it looks like I am stuck building a table to pass to Excel. (unless anyone has any ideas on other classes!)</p> <p>I am having an issue with the code, it exports just fine to excel and the formatting is correct for the first row. On all subsequent rows, all data is 'dumped' into one cell. Here is the code:</p> <pre><code>$table .= '&lt;table border="0" cellpadding="0" cellspacing="0"&gt;&lt;tr&gt;'; $table .= '&lt;td style="background-color:#000099;color:#FFFFFF;"&gt;Date&lt;/td&gt;'; $table .= '&lt;td style="background-color:#000099;color:#FFFFFF;"&gt;Name&lt;/td&gt;'; $table .= '&lt;td style="background-color:#000099;color:#FFFFFF;"&gt;Address&lt;/td&gt;'; $table .= '&lt;td style="background-color:#000099;color:#FFFFFF;"&gt;City&lt;/td&gt;'; $table .= '&lt;/tr&gt;'; while($row=mysql_fetch_array($result)){ $table .= '&lt;tr&gt;'; $table .= '&lt;td style="background-color:#FFFCCC"&gt;'.$row['date'].'&lt;/td&gt;'; $table .= '&lt;td style="background-color:#FFFCCC"&gt;'.$row['name'].'&lt;/td&gt;'; $table .= '&lt;td style="background-color:#FFFCCC"&gt;'.$row['address'].'&lt;/td&gt;'; $table .= '&lt;td style="background-color:#FFFCCC"&gt;'.$row['city'].'&lt;/td&gt;'; $table .= '&lt;/tr&gt;'; $table .= '&lt;/table&gt;'; } header("Pragma: public"); header("Expires: 0"); header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("Content-Type: application/force-download"); header("Content-Type: application/octet-stream"); header("Content-Type: application/download");; header("Content-Disposition: attachment;filename=Itinerary-$today.xls "); header("Content-Transfer-Encoding: binary "); echo $table; </code></pre> <p>Appreciate any thoughts anyone can share on this subject!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload