I've been playing with the following script for the last hour now and can not figure out what the hell is going wrong.
What's the idea:- Basically I have a database that holds data on images and I am calling that data (image filenames), trying to put it into an array to then pass to a zip creation script.
Here's what I have:-
$query_ImageCollect = "SELECT * FROM image_data WHERE image_dealerid='$dealer_id' AND imagename LIKE '$imageName'";
$ImageCollect = mysql_query($query_ImageCollect, $vwconn) or die(mysql_error());
$row_ImageCollect = mysql_fetch_assoc($ImageCollect);
$totalRows_ImageCollect = mysql_num_rows($ImageCollect);
$counter=0;
do{
$counter=$counter+1;
$ImageUrl=$row_ImageCollect['image_url'];
$getFileNames="../../images/$ImageUrl";
if($counter==1){
$getFiles="'$getFileNames'";
}else{
$getFiles="$getFiles, '$getFileNames'";
}
} while ($row_ImageCollect = mysql_fetch_assoc($ImageCollect));
$groupFiles=array("$getFiles");
$zipName="Pictures.zip";
$zip = new ZipArchive;
$zip->open($zipName, ZipArchive::CREATE);
foreach ($groupFilesas $file) {
$zip->addFile($file);
}
$zip->close();
header('Content-Type: application/zip');
header('Content-disposition: attachment; filename='.$zipName);
header('Content-Length: ' . filesize($zipName));
readfile($zipName);
I also tried parsing the results directly into an array but it also failed:-
$query_ImageCollect = ("SELECT image_url FROM image_data WHERE image_dealerid='$dealer_id' AND imagename LIKE '$imageName'") or die(mysql_error());
while( $row = mysql_fetch_assoc( $query_ImageCollect )){
$groupFiles[] = $row;
}
$zipName="Pictures.zip";
$zip = new ZipArchive;
$zip->open($zipName, ZipArchive::CREATE);
foreach ($groupFilesas $file) {
$zip->addFile($file);
}
$zip->close();
header('Content-Type: application/zip');
header('Content-disposition: attachment; filename='.$zipName);
header('Content-Length: ' . filesize($zipName));
readfile($zipName);
Any help / suggestions would be much appreciated. Thanks in advance :)