I have a HTML table in php code , I need the content of that table to be exported in to .csv file through a button (Hyperlink) from the same page.
Please support me in this.
<html>
<body>
<?php
$dt1 = $_POST["bday1"];
$dt2 = $_POST["bday2"];
// Create connection to Oracle
$conn = oci_connect("cse", "mahesh123", "XE");
$query = "select
trdt,SYMBOL,BID_PRICE,ASK_PRICE,OPEN_PRICE,
HIGH_PRICE,LOW_PRICE,LAST_TRADED_PRICE,CLOSE_PRICE,
to_char(TRADE_VOLUME,'999,999,999,999')TR_Volume,
to_char(SHARE_VOLUME,'999,999,999,999')Share_Vol,
to_char(TURNOVER,'999,999,999,999') Turnover,
to_char(ISSUED_QUANTITY ,'999,999,999,999') Issued_Qty
from daily_trades where trdt between TO_DATE('$dt1','YYYY-MM-
DD')and TO_DATE('$dt2','YYYY-MM-DD')
and symbol='PABC-N-0000' order by trdt";
//Date Symbol Short_Name Bid_Price Ask_Price
Open_Price High_Price Low_Price Last_Traded_Price
Close_Price Trade_Volume Share_Volume Turnover
Issued_Qty
$stid = oci_parse($conn, $query);
$r = oci_execute($stid);
// Fetch each row in an associative array
print '<table style="font-size:13px;">';
echo "<tr><th >Date</th><th>Symbol</th><th>Bid_Price</th>
<th>Ask_Price</th><th>Open_Price</th><th>High_Price</th>
<th>Low_Price</th><th>Last_Traded</th>
<th>Close_Price</th><th>Trade_Volume</th><th>Share_Volume</th>
<th>Turnover</th><th>Issued_Qty</th></tr>";
while ($row = oci_fetch_array($stid, OCI_RETURN_NULLS+OCI_ASSOC)) {
print '<tr>';
foreach ($row as $item) {
print '<td>'.($item !== null ? htmlentities($item, ENT_QUOTES) :
' ').'</td>';
}
print '</tr>';
}
print '</table>';
?>
</body>
</html>
I need to export the data in to a csv file.