$output = "";
if(isset($_POST['submit']))
{
$qry = mysql_query("SELECT * FROM ch_countries");
if(mysql_num_rows($qry)>0)
{
$output.= '<table class="table" border="1">
<tr>
<th>ID</th>
<th>Country Code</th>
<th>Country Name</th>
</tr> ';
while($row= mysql_fetch_array($qry))
{
$output .= '
<tr>
<td>'.$row["id"].'</td>
<td>'.$row["country_code"].'</td>
<td>'.$row["country_name"].'</td>
</tr>
';
}
$output .= '</table>';
//important part
header("Conten-Type: application/xls");
header("Content-Disposition: attachment; filename = download.xls");
echo $output;
}
}
if(isset($_POST['submit']))
{
$qry = mysql_query("SELECT * FROM ch_countries");
if(mysql_num_rows($qry)>0)
{
$output.= '<table class="table" border="1">
<tr>
<th>ID</th>
<th>Country Code</th>
<th>Country Name</th>
</tr> ';
while($row= mysql_fetch_array($qry))
{
$output .= '
<tr>
<td>'.$row["id"].'</td>
<td>'.$row["country_code"].'</td>
<td>'.$row["country_name"].'</td>
</tr>
';
}
$output .= '</table>';
//important part
header("Conten-Type: application/xls");
header("Content-Disposition: attachment; filename = download.xls");
echo $output;
}
}
No comments:
Post a Comment