fcruz5
asked on
PHP Mailing Labels by Range
Hi,
The following code will display a form where I can type in the id's seperated by comma to print out the mailing labels that I want.
I want to add these two fields so I can specify a range of id's to print mailing labels for:
Choose a Range: <input type="text" name="range1" /> <input type="text" name="range2 />
For example, this is what the 2 new fields would do:
In the first field I can put id# "200" and the next field I may put "300". So, when I click "Generate Labels" it will print out all of the id's from the 200 - 300 range.
How can I do something like this?
Below is the code that I have now:
<?php
if(!empty($_POST['labels'] ))
{
define('FPDF_FONTPATH','fo nt/');
require_once('PDF_Label.ph p');
require('conn.php');
$labels = explode(',', $_POST['labels']);
$pdf = new PDF_Label('L7163', 'mm', 1, 2);
$pdf->Open();
$pdf->AddPage();
foreach($labels as $labelId)
{
$query = "SELECT work.id, work.title, work.name, work.address, work.city, work.state, work.zip, region.id
FROM work work, region region
WHERE work.id = region.id AND work.id = " . $labelId;
$result = mysql_query($query);
$row = mysql_fetch_assoc($result) ;
//for($i=1;$i<=40;$i++)
$pdf->Add_PDF_Label(sprint f("%s\n%s\ n%s\n%s, %s, %s", $row['title'], $row['name'], $row['address'], $row['city'], $row['state'], $row['zip'] ));
}
$pdf->Output();
}
?>
<form method="post" action="<?php echo $_SERVER['SCRIPT_NAME'];?> ">
List ids separated by a comma: <input type="text" name="labels" /><br />
<input type="submit" value="Generate Labels" />
<!--new fields go here-->
</form>
The following code will display a form where I can type in the id's seperated by comma to print out the mailing labels that I want.
I want to add these two fields so I can specify a range of id's to print mailing labels for:
Choose a Range: <input type="text" name="range1" /> <input type="text" name="range2 />
For example, this is what the 2 new fields would do:
In the first field I can put id# "200" and the next field I may put "300". So, when I click "Generate Labels" it will print out all of the id's from the 200 - 300 range.
How can I do something like this?
Below is the code that I have now:
<?php
if(!empty($_POST['labels']
{
define('FPDF_FONTPATH','fo
require_once('PDF_Label.ph
require('conn.php');
$labels = explode(',', $_POST['labels']);
$pdf = new PDF_Label('L7163', 'mm', 1, 2);
$pdf->Open();
$pdf->AddPage();
foreach($labels as $labelId)
{
$query = "SELECT work.id, work.title, work.name, work.address, work.city, work.state, work.zip, region.id
FROM work work, region region
WHERE work.id = region.id AND work.id = " . $labelId;
$result = mysql_query($query);
$row = mysql_fetch_assoc($result)
//for($i=1;$i<=40;$i++)
$pdf->Add_PDF_Label(sprint
}
$pdf->Output();
}
?>
<form method="post" action="<?php echo $_SERVER['SCRIPT_NAME'];?>
List ids separated by a comma: <input type="text" name="labels" /><br />
<input type="submit" value="Generate Labels" />
<!--new fields go here-->
</form>
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.