I have a php script which outputs my search into excel. It doesn't do the formatting right and it includes my menu from my Website and my searchbar.
How can I bring it to not output the menu or the searchbar? Or should I just export the data into csv? I'm not sure what's easier..
Heres my current working code :
normalsearch.php :
<html>
<header>
<?php include 'menu2.php'; ?>
<br>
<form action="normalsearch.php" method="GET">
LF. Nr / Code :
<input type="text" name="query" />
<input type="submit" value="Suchen" />
</form>
<form action="export.php" method="GET">
<input type="text" name="query" />
<input type="submit" value="Excel">
</form>
</header>
<br>
<br>
<body>
<table border="1">
<tr>
<th>Number</th>
<th>Product ID</th>
<th>Description</th>
<th>Stock</th>
</tr>
<?php
$query = $_GET['query'];
//connection to mysql
mysql_connect("host", "user", "password"); //server , username , password
mysql_select_db("database");
//query get data
$sql = mysql_query("SELECT * FROM database WHERE productID LIKE '%".$query."%' LIMIT 100");
$no = 1;
while($data = mysql_fetch_assoc($sql)){
echo '
<tr>
<td>'.$no.'</td>
<td>'.$data['productID'].'</td>
<td>'.$data['description'].'</td>
<td>'.$data['stock'].'</td>
</tr>
';
$no++;
}
?>
</body>
</html>
export.php :
<?php
// The function header by sending raw excel
header("Content-type: application/vnd.ms-excel");
// Defines the name of the export file "codelution-export.xls"
header("Content-Disposition: attachment; filename=Artikelsuche.xls");
// Add data table
include 'normalsearch.php';
?>