PHP/mysql中的标头出现问题 [英] problem with header in PHP/mysql
本文介绍了PHP/mysql中的标头出现问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
以下代码在我的名为option.php的文件中
Following code is on my file named option.php
<head>
<style type="text/css">
</style>
</head>
<a href="index.php">Home</a>
<b><u><center><font size="100"></font> ******</center></u></b>
<hr />
<script type="text/javascript">
function printpage()
{
window.print();
}
</script>
<?php <br mode="hold" /?>
if(isset($select)&&$select!="")
{
$select=$_GET['select'];
}
?>
<center><form id="form1" name="form1" method="post" action="#" target="_blank">
Select Name of telecaller :
<select name="select">
<option value="">--- Select ---</option>
<?php <br mode="hold" /?>$con = mysql_connect("localhost","root","");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db('import2',$con) or die('could not select database') ;
$res=mysql_query("SELECT telecaller FROM temp1 ");
// Show records by while loop.
while($row=mysql_fetch_assoc($res))
{
print("<option value=$row[telecaller]>$row[telecaller]</option>");
}
print("</select>");
?>
Select Date :
<select name="select1">
<option value="">--- Select ---</option>
<?php <br mode="hold" /?>$res2=mysql_query("SELECT date FROM temp1 GROUP BY date");
// Show records by while loop.
while($row=mysql_fetch_assoc($res2))
{
print("<option value=$row[date]>$row[date]</option>");
}
print("</select>");
?>
<input type="submit" name="submit" value="Select" />
</form>
<hr />
<p>
$result=mysql_query("SELECT id,date,mobno,state,type,telecaller FROM temp1 WHERE (telecaller='$_POST[select]\r' AND date='$_POST[select1]') ORDER BY id ASC ") or die(mysql_error());
echo"<div id="printable">";
//$result2 mysql_query("SELECT id,date,mobno,state,type,telecaller FROM temp1 WHERE date='$_POST[select]' OR telecaller='$_POST[select]\r' ") or die(mysql_error());
print("");
echo"<form name='form2' target='_blank'>";
print("<table border="1" cellspacing="5" cellpadding="12">
<tr>
<th>Sr.No:</th>
<th>Date:</th>
<th>Mobile No:</th>
<th>State:</th>
<th>Type:</th>
<th>CIExe.:</th>
</tr>");
while($row=mysql_fetch_array($result))
{
print("<tr>");
print("<td>" . $row['id'] . "</td>");
print("<td>" . $row['date'] . "</td>");
print("<td>" . $row['mobno'] . "</td>");
print("<td>" . $row['state'] . "</td>");
print("<td>" . $row['type'] . "</td>");
print("<td>" . $row['telecaller'] . "</td>");
print("</tr>");
}
?>
<table><tr><a href="option2.php"> View data by Date </a></tr></table>
<br /> Download this report as
<a href="export1.php">
mce_href="export1.php">Excel</a>
<input type="button" value="Print this page" önclick="printpage()" />
and on another file...
include 'connection.php';
function export_excel_csv()
{
$sql = "SELECT id,date,mobno,state,type,telecaller FROM temp1 WHERE date='$_POST[select]' OR telecaller='$_POST[select1]\r' ORDER BY id ASC ";
$rec = mysql_query($sql) or die (mysql_error());
$num_fields = mysql_num_fields($rec);
header("Content-type: application/octet-stream");
header("Content-Disposition: attachment; filename=reports.xls");
header("Pragma: no-cache");
header("Expires: 0");
for($i = 0; $i < $num_fields; $i++ )
{
$header = mysql_field_name($rec,$i)."\t";
print "$header";
}
print "\n";
while($row = mysql_fetch_row($rec))
{
$line = '';
foreach($row as $value)
{
if((!isset($value)) || ($value == ""))
{
$value = "\t";
}
else
{
$value = str_replace( '"' , '""' , $value );
$value = '"' . $value . '"' . "\t";
}
$line .= $value;
}
$data = trim( $line ) . "\n";
print "$data";
}
print "\n";
$data = str_replace("\\r" , "" , $data);
if ($data == "")
{
$data = "\\n No Record Found!\n";
}
}
export_excel_csv();
?>
现在我收到有关头文件的错误.该信息已经发送.但是在option.php中我没有使用过这样的头.
我上面的编码有什么问题...任何人都可以帮助我.
Now I am getting the error about header file.. that information already send.but there is no such header I already used in option.php
What is wrong with my above coding...can anyone help me.
推荐答案
select)&&
select)&&
select !=") {
select!="") {
select =
这篇关于PHP/mysql中的标头出现问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文