最初は英語で失礼したいのですが、問題があります
この方法でデータベースからテーブルを作成します。
//the connection goes right, so I don't put it into my code
<table id="database">
<tr>
<th>Title1</th>
<th>Title2</th>
<th>Title3</th>
<th>Title4</th>
</tr>
<?php
$result = mysql_query("SELECT * FROM `table`");
while($row = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td>".$row['Column1']."</td>";
echo "<td>".$row['Column2']."</td>";
echo "<td>".$row['Column3']."</td>";
echo "<td>".$row['Column4']."</td>";
echo "</tr>";
}
?>
</table>
問題は、テーブルをオンラインで削除したいので、これらのデータをファイルに入れようとしているということです。これらの列をコンピューターのローカルに保存する理由があります。
私はすでに試してみましTCPDF
たhtml2pdf
これらを に入れる義務はありませんpdf
が、保存したいだけです。
あなたが私を助けてくれることを願っています。
更新:与えられた2つの良い解決策があります。しかし、私は自分に問題があったAcrobat Reader
ので、これを選びました:
<?php
ob_start();
?>
<table id="database">
<tr>
<th>Title1</th>
<th>Title2</th>
<th>Title3</th>
<th>Title4</th>
</tr>
<?php
$result = mysql_query("SELECT * FROM `table`");
while($row = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td>".$row['Column1']."</td>";
echo "<td>".$row['Column2']."</td>";
echo "<td>".$row['Column3']."</td>";
echo "<td>".$row['Column4']."</td>";
echo "</tr>";
}
?>
</table>
<?php
$output = ob_get_contents();
$filename = "column".time().".xls";
file_put_contents($filename, $output) or die("can't write to the file");
?>
<a href="<?php echo $filename; ?>">Print</a>