I'm making a script that queries a db, and present the user with a list of results. They then can either click on the magic "PDF" button to generate a PDF and view the PDF, or they will have the option of using checkboxes to select many and instead it will visit a page with links to all of the generated PDF's (so that a lot can be printed at once). The problem is that I'm getting the same number listed over and over.
###index.php###
while(!$rs->EOF)
{
$invoice = $rs->fields["invoice"];
print "
<form action='/pdf.php' method='post'>
<input type='hidden' value=$invoice name='invoice'>
<input type='image' src='pdf.png'>
<input type='checkbox' value='$invoice' name='checkbox'>
<strong>Client Name</strong> ".$rs->fields["company_name"]." (<strong>invoice#</strong>: ".$rs->fields["invoice"]. " (<strong>Bill Date</strong>: ".$rs->fields["bill_date"].")<br>
<input type=submit>
</form>
";
$rs->moveNext();
}
############
###pdf.php###
<?
require_once('FPDF/fpdf.php');
if (isset($POST['invoice'])){
print "$invoice<br>";
if (isset($POST["checkbox"])){
print "$checkbox<br>";
}
}else{
print "it wasn't set";
}
If I check the box next to 1 and 2 and then click the PDF! button next to 1 the next page says:
###output###
1
1
How would I get it to put:
1
2
and if I check 1, 3,5,10 for it print out
1
3
5
10
any ideas?