I have some pdf files in folder 3_day_notice_fad_pdf. Now I have to download pdf files in zip form, based on query condition.
<?php
include("connection.php");
extract($_REQUEST);
$query=mysql_query("select fad_html_name from fad_record where t_id='$word'") or die(mysql_error());
while($result=mysql_fetch_array($query,MYSQL_ASSOC))
{
extract($result);
$movies_id[] = "3_day_notice_fad_pdf/$fad_html_name";
}
$movies_id = array();
//print_r($movies_id);
$zipname = 'file.zip';
$zip = new ZipArchive;
$zip->open($zipname, ZipArchive::CREATE);
foreach ($movies_id as $file) {
$zip->addFile($file);
}
$zip->close();
header('Content-Type: application/zip');
header('Content-disposition: attachment; filename='.$zipname);
header('Content-Length: ' . filesize($zipname));
readfile($zipname);
?>
Zip file is working perfectly, but it is downloading all the files present in folder 3_day_notice_fad_pdf. It is not validating with condition where t_id='$word' in query.