<? ob_start(); ?><?php //session_start();
include('ziplib.php');
//require 'database.php';
//require 'zip/gnu-lgpl.txt';
require 'zip/pclzip.lib.php';
//
if($_POST['download']) // from button name="delete"
{
$checkbox = $_POST['checkbox']; //from name="checkbox[]"
$countCheck = count($_POST['checkbox']);
for($i=0;$i<$countCheck;$i++)
{
$del_id = $checkbox[$i];
if(isset($_GET['del_id']))
{
$id = $_GET['del_id'];
$query = "SELECT * FROM updatenews WHERE id = $del_id";
$result = mysqli_query('$query') or die('Error, query failed');
list($filename, $type, $size, $content) = mysqli_fetch_array($result);
//header("Content-type: Content-Type: application/msword; charset=ISO-8859-1");
//header("Content-Disposition: attachment; filename=\"$filename\"");
//header("Content-length: $size");
//echo "$content";
//echo "$query";
}
if(!$result)
{
echo "$del_id";
$con=mysql_connect('localhost','wwwpmni_root','vertrigo123./.');
if(!$con)
{
die('could not connect:' .mysql_error());
}
mysql_select_db('wwwpmni_pmn',$con);;
$sql = "SELECT * FROM updatenews where id=$del_id";
$rt = mysql_query ($sql,$con);
//print "$sql<br>";
$zip = new Ziplib();
while($nt=mysql_fetch_array($rt)){
//header '$nt[filename]<br>';
//header "$nt[content]"; // name class and mark will be printed with one line break at the end
//header ("Content-type: Content-Type: application/msword; charset=ISO-8859-1<br>");
//header ("Content-Disposition: attachment; filename=\"$nt[filename]\"<br>");
//header ("Content-length: $nt[size]<br>");
echo "<font face='chanakya' size='5' color='red'>$nt[content]</font><br><br>";
$files_to_zip = $nt[content];
$zip->zl_add_file($nt[content].$files_to_zip,$files_to_zip);
//$zip->close();
//then send the headers to foce download the zip file
header("Content-type: application/zip");
header("Content-Disposition: attachment; filename=$archive_file_name");
header("Pragma: no-cache");
header("Expires: 0");
readfile("$archive_file_name");
exit;
//if true, good; if false, zip creation failed
//$result = create_zip($files_to_zip,'my-archive.zip');
}
//echo "$content";
//header('Location: _delete.php');
}
else
{
echo "Error: ".mysql_error();
}mysql_free_result($rt);
mysql_close($con);
}
}
?><? ob_flush(); ?>
klsatellite4 0 Newbie Poster
<? ob_start(); ?><?php //session_start();
include('ziplib.php');
//require 'database.php';
//require 'zip/gnu-lgpl.txt';
require 'zip/pclzip.lib.php';
//
if($_POST['download']) // from button name="delete"
{
$checkbox = $_POST['checkbox']; //from name="checkbox[]"
$countCheck = count($_POST['checkbox']);
for($i=0;$i<$countCheck;$i++)
{
$del_id = $checkbox[$i];
if(isset($_GET['del_id']))
{
$id = $_GET['del_id'];
$query = "SELECT * FROM updatenews WHERE id = $del_id";
$result = mysqli_query('$query') or die('Error, query failed');
list($filename, $type, $size, $content) = mysqli_fetch_array($result);
//header("Content-type: Content-Type: application/msword; charset=ISO-8859-1");
//header("Content-Disposition: attachment; filename=\"$filename\"");
//header("Content-length: $size");
//echo "$content";
//echo "$query";
}
if(!$result)
{
echo "$del_id";
$con=mysql_connect('localhost','wwwpmni_root','vertrigo123./.');
if(!$con)
{
die('could not connect:' .mysql_error());
}
mysql_select_db('wwwpmni_pmn',$con);;
$sql = "SELECT * FROM updatenews where id=$del_id";
$rt = mysql_query ($sql,$con);
//print "$sql<br>";
$zip = new Ziplib();
while($nt=mysql_fetch_array($rt)){
//header '$nt[filename]<br>';
//header "$nt[content]"; // name class and mark will be printed with one line break at the end
//header ("Content-type: Content-Type: application/msword; charset=ISO-8859-1<br>");
//header ("Content-Disposition: attachment; filename=\"$nt[filename]\"<br>");
//header ("Content-length: $nt[size]<br>");
echo "<font face='chanakya' size='5' color='red'>$nt[content]</font><br><br>";
$files_to_zip = $nt[content];
$zip->zl_add_file($nt[content].$files_to_zip,$files_to_zip);
//$zip->close();
//then send the headers to foce download the zip file
header("Content-type: application/zip");
header("Content-Disposition: attachment; filename=$archive_file_name");
header("Pragma: no-cache");
header("Expires: 0");
readfile("$archive_file_name");
exit;
//if true, good; if false, zip creation failed
//$result = create_zip($files_to_zip,'my-archive.zip');
}
//echo "$content";
//header('Location: _delete.php');
}
else
{
echo "Error: ".mysql_error();
}mysql_free_result($rt);
mysql_close($con);
}
}
?><? ob_flush(); ?>
<?php
$con=mysql_connect('localhost','wwwpmni_root','vertrigo123./.');
if(!$con)
{
die('could not connect:' .mysql_error());
}
mysql_select_db('wwwpmni_pmn',$con);; // All database details will be included here
if (isset($_GET["page"])) { $page = $_GET["page"]; } else { $page=1; };
$start_from = ($page-1) * 10;
$sql = "SELECT * FROM updatenews LIMIT $start_from, 10";
$rs_result = mysql_query ($sql,$con);
$query = "SELECT id, subject FROM updatenews LIMIT $start_from, 10";
// run the query and store the results in the $result variable.
$result = $mysqli->query($query) or die(mysqli_error($mysqli));
if ($result) {
// create a new form and then put the results
// indto a table.
echo "<form method='post' action='download.php' target='_blank'>";
echo "<table cellspacing='0' cellpadding='15'>
<th width='50' bgcolor='blue'><h1><font color='white'>Id</font></h1></th>
<th width='750'bgcolor='blue'><h1><font color='white'>Headline</font></h1></th>
<th width='50'bgcolor='blue'><h1><font color='white'>Download</font></h1></th>
";
while ($row = $result->fetch_object()) {
$Headline = $row->subject;
//$email = $row->email;
//$image = $row->product_img;
$id = $row->id;
$s=2;
print "<table>\n";
for($y=1;$y<=$row;$y++)
{
if($bgcolor=='green'){$bgcolor='red';}
else{$bgcolor='green';}
print "<tr>";
print "<td width=50 bgcolor=$bgcolor><font size='5' color='white'>$id</font></td>";
print"<td width=800 bgcolor=$bgcolor><font face='chanakya' size='5' color='white'>";
print "$Headline";
print "</font></td>";
print "<td width=100 bgcolor=$bgcolor><font size='5' color='white'><input type='checkbox' name='checkbox[]' id='checkbox[]' value=$id />";print"</font></td>";
print"</tr>";
}
}
"</table>";
echo "</table><p align='center'><input id='download' target='_blank' type='submit' class='button' name='download' value='Download Selected Items'/></p>
</form>";
}
?>
<table align="center"><tr>
<td>
<?php
$sql = "SELECT COUNT(Name) FROM updatenews";
$rs_result = mysql_query($sql,$con);
$row = mysql_fetch_row($rs_result);
$total_records = $row[0];
$total_pages = ceil($total_records /10);
for ($i=1; $i<=$total_pages; $i++)
{
echo "<font size='2' color='red'><a href='_delete.php?page=".$i."'>|".$i."|</a></font>";
}
?></td></tr></table>
Edited by nav33n because: Please use [code][/code] tags to wrap your code for easy readability.
Usernamex235 0 Junior Poster in Training
A "headers already sent" warning arises when a script tries to modify header data after sending content (for example using echo). When this content is sent, the server will send a standard set of headers followed by that content, so it cannot modify those headers any more (because it's now actually sending the html).
In you while loop you have:
#
echo "<font face='chanakya' size='5' color='red'>$nt[content]</font><br><br>";
#
$files_to_zip = $nt[content];
#
$zip->zl_add_file($nt[content].$files_to_zip,$files_to_zip);
#
#
//$zip->close();
#
//then send the headers to foce download the zip file
#
header("Content-type: application/zip");
- Notice you are trying to modify a http header after using echo.
If you post the line number of the error we can confirm that. Hope this helps :)
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.