Hello oh wise ones, worked out my exporting to xls issue however coming up with a wee problem. I'm using frames :rolleyes: , when i click on my export button in my mainframe window excel opens up in the frame rather than saving the file as <myname>.xls.
When i add the 'attachment;' to the 'header("Content-disposition' bit the file does save but saves the file as '<phpexportcodefile>.php' when i want to export the file as <myname>.xls. All the data within the files is correct, just want it named as a .xls file so i get fewer questions form the users etc.
Here's the code, any ideas will be appreciated and in return i promise to plough through these forums as my skills increase to be the yoda of all things php etc lol
<?
$connection = mysql_connect("localhost", "<username>", "<password>");
$db_name = "slipsey";
$table_name = "contact";
$db = mysql_select_db($db_name, $connection);
$sql = $_POST['sqlfwd'];
$result = mysql_query($sql, $connection);
header("Content-type: application/vnd.ms_excel");
header("Content-disposition: filename=contactsearch.xls");
echo "Firstname\tSurname\tShareholder\tDepartment\tAddress1\tAddress2\tAddress3\tAddress4\tAddress5\tPostalcode\tCountry\n";
for($i= 0; $i<mysql_num_rows($result); $i++) {
$var1[$i] = mysql_result($result,$i,"firstname");
$var2[$i] = mysql_result($result,$i,"surname");
$var3[$i] = mysql_result($result,$i,"shareholder");
$var4[$i] = mysql_result($result,$i,"department");
$var5[$i] = mysql_result($result,$i,"address1");
$var6[$i] = mysql_result($result,$i,"address2");
$var7[$i] = mysql_result($result,$i,"address3");
$var8[$i] = mysql_result($result,$i,"address4");
$var9[$i] = mysql_result($result,$i,"address5");
$var10[$i] = mysql_result($result,$i,"postalcode");
$var11[$i] = mysql_result($result,$i,"country");
echo "$var1[$i]\t$var2[$i]\t$var3[$i]\t$var4[$i]\t$var5[$i]\t$var6[$i]\t$var6[$i]\t$var8[$i]\t$var9[$i]\t$var10[$i]\t$var11[$i]\n";
}
?>
😕