This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ require_once './includes/config.php'; define('FPDF_FONTPATH', './includes/fpdf/font/'); require_once './includes/fpdf/fpdf.php'; require_once './includes/fpdf/label/PDF_Label.php'; $pdf = new PDF_Label('5160'); $pdf->Open(); $pdf->AddPage(); $pdf->Set_Font_Size(10); // Print labels... $labelQ = "SELECT d.cardNo, count(o.cardNo), \n\t\tCASE WHEN SUBSTR(address,-1) = '\n' THEN SUBSTR(address, 1, LENGTH(address)-1) ELSE address END AS address, \n\t\tcity, state, \n\t\tCASE WHEN LENGTH(zip)>5 THEN CONCAT(SUBSTR(zip,1,5), '-', SUBSTR(zip,5,4)) ELSE zip END AS zip \n\tFROM details AS d\n\tINNER JOIN owners AS o\n\tON d.cardNo = o.cardNo\n\tWHERE address IS NOT NULL AND address <> '' AND address <> 'n/a'\n\t\tAND city IS NOT NULL AND city <> ''\n\t\tAND state IS NOT NULL AND state <> ''\n\t\tAND zip IS NOT NULL AND zip <> '' AND zip <> 0\n\t\tAND d.noMail = false\n\t\tAND o.memType IN (1, 2, 7)\n\tGROUP BY cardNo\n\tORDER BY zip ASC"; $labelR = mysqli_query($DBS['comet'], $labelQ); if (!$labelR) { printf('Error: %s, Query: %s', mysqli_error($DBS['comet']), $labelQ); exit; } else { while (list($cardNo, $count, $address, $city, $state, $zip) = mysqli_fetch_row($labelR)) { $detailQ = "SELECT CONCAT(firstName, ' ', lastName) AS name FROM owners WHERE cardNo = {$cardNo} AND personNum = 1"; $detailR = mysqli_query($DBS['comet'], $detailQ); if (!$detailR) { printf('Error: %s, Query: %s', mysqli_error($DBS['comet']), $detailQ); exit; } list($name) = mysqli_fetch_row($detailR);