hriti 0 Light Poster

hello everyone
i am having problem while creating zip file..when i use static images then it works well...but when i coonect it wiTH database it stops working..
can anyone please tell me....

my code is:

`

<?php include("include/connection.inc.php");
    $error = "";        //error holder
    if(isset($_POST['createpdf'])){
        $post = $_POST;     
        $file_folder = "./store/product/images/";   // folder to load files
         if(extension_loaded('zip')){    // Checking ZIP extension is available
            if(isset($post['files']) and count($post['files']) > 0){    // Checking files are selected
                $zip = new ZipArchive();            // Load zip library 
                $zip_name = time().".zip";          // Zip name
                if($zip->open($zip_name, ZIPARCHIVE::CREATE)!==TRUE){       // Opening zip file to load files
                    $error .=  "* Sorry ZIP creation failed at this time<br/>";
                }
                foreach($post['files'] as $file){               
                    $zip->addFile($file_folder.$file);          // Adding files into zip
                }
                $zip->close();
                if(file_exists($zip_name)){
                    // push to download the zip
                    header('Content-type: application/zip');
                    header('Content-Disposition: attachment; filename="'.$zip_name.'"');
                    readfile($zip_name);
                    // remove zip file is exists in temp path
                    unlink($zip_name);
                }

            }else
                $error .= "* Please select file to zip <br/>";
        }else
            $error .= "* You don't have ZIP extension<br/>";
    }
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Lumax LED Lights</title>
</head>
<body>
<center><h1>Create Zip</h1></center>
<form name="zips" method="post" action="">
<?php if(!empty($error)) { ?>
<p style=" border:#C10000 1px solid; background-color:#FFA8A8; color:#B00000;padding:8px; width:588px; margin:0 auto 10px;"><?php echo $error; ?></p>
<?php } ?>
<table width="40%" border="1" align="center" cellpadding="2" cellspacing="0" style="border-collapse:collapse; border:#ccc 1px solid;">
  <tr>
    <td width="50" align="center">*</td>
     <td width="150">File</td>
  </tr>
  <?php  $sub_id=$_GET['sub_id'];
        $q="select * from product WHERE id = '$sub_id' and `status` ='A' ORDER BY sort_id desc";
        $output=mysql_query($q) or die (mysql_error().$q);
        $rows=mysql_fetch_array($output);
        $count=mysql_num_rows($output);

        $arr = $rows['image'];
        $i1=explode("#",$arr); 



foreach($i1 as $i =>$key) {
$i >0;
      $i.' '.$key .'</br>';

} 
        for($j=0;$j<=$i;$j++)
        {

    ?>  
  <tr>
    <td align="center"><input type="checkbox" name="files[]" value="flowers.jpg" /></td>
     <td><img src="./store/product/images/<?php echo $i1[$j];?>" width="100px" height="100px">
    <a href="./store/product/images/<?php echo $i1[$j];?>">click to view full image</a></td>
  </tr> 
  <?php } ?>
  <tr>
    <td colspan="3" align="center">
        <input type="submit" name="createpdf" style="border:0px; background-color:#800040; color:#FFF; padding:10px; cursor:pointer; font-weight:bold; border-radius:5px;" value="Download as ZIP" />&nbsp;
        <input type="reset" name="reset" style="border:0px; background-color:#D3D3D3; color:#000; font-weight:bold; padding:10px; cursor:pointer; border-radius:5px;" value="Reset" />
    </td>
    </tr>
</table>

</form>
</body>
</html>

`