I need to export the result of a query that I'm printing on a table in php, I currently have two tables (queries) in my page that are shown at par but I need export to an excel file the result of a.
this is my query
<form type="submit" method="post" role="form-
horizontal" id="form-fil">
<div class="form-group">
<div class="col-sm-2" id="tittle">
<h1>Formulario</h1>
<select class="form-control"
name="selRez" id="selRez" >
<?php
$query="select * from tabla1 where clave = $var;";
$result = pg_query($query) or die('Query failed: ' . pg_last_error());
$rows = pg_num_rows ($result);
$i = pg_num_fields($result);
//Construyo mi tabla
while ($line = pg_fetch_array($result)){
if ($line[0] <> "") {
echo "<option value='$line[0]' >$line[1]
</option>";
}else{
echo"<option > </option>";
}
}
?>
</select>
</div>
</div>
</form>
I would like to add the functionality that I tell you in this part of the code
<td aling= "right" ><a href="excelTabla.php" target"_blank" style="display:inline"><img src="./img/excelIcon.png"</a></td>
I hope you can help me, I thank you for beforehand