This code works fine when only one of the columns in mysql has been set with a value and the name and filename process correctly. I'm having problems when both values have been set. I only get the last one name and filename to be popped into the array. The result from the query is as follows: Lit1 =1 and Lit 2 =1, both are executed, because the update function works for both. I get the last document in the array, but not the first one. So the problem is, I think I'm overwriting the array and only the last value is in. Any help!
<?php
functionName{
while ($row = mysql_fetch_array($result)) {
if($row['LIT1'] != NULL)
{
$name= "ABC.pdf";
$fileName = "../pdf/ABC.pdf";
$updat= "update master set LIT1SENT='1' where UF13='$email'" ;
$rs = mysql_query($updat, $web)
or die('Could not query:' .mysql_error());
}
if($row['LIT2'] != NULL)
{
$name = "DEF.pdf";
$fileName = "../pdf/DEF.pdf";
$updat= "update master set LIT2SENT='1' where UF13='$email'" ;
$rs = mysql_query($updat, $web)
or die('Could not query:' .mysql_error());
}
$file = fopen("$fileName",'rb');
$data = fread($file, filesize($fileName));
fclose($file);
$docData = Array();
$aDoc['name'] = $name;
$aDoc['data'] = $data;
$docData[] = $aDoc;
}
return $docData;
}
?>