The_FedEx_Guy wrote:
> if that customer has 4 jobs and he wants to make an
invoice for 3 jobs then
> he wants a checkbox to click on every row that he wants
to add.
>
> My Problem is I do not know how to do this and pass the
same value (job_id) to
> the invoice.php
The checkboxes need to have the same name, and their values
passed as an
array to the next page.
Change this:
> <label>
> <input name="add" type="checkbox" id="add"
value="Yes" />
> </label>
to this:
<label>
<input name="add[]" type="checkbox" id="add_<?php echo
$ac_sw1; ?>"
value="<?php echo $row_jobs['job_id']; ?>" />
</label>
The square brackets after the name turn "add" into an array.
I have also
used your row counter, $ac_sw1, to create a unique ID for
each checkbox.
Finally, the value of each checkbox is set to its job_id.
You also need to wrap the checkboxes in a form, and use a
submit button
to send the selection to the next page.
In the next page, you can extract the values from
$_POST['add'] and use
them in a SQL query like this:
if (isset($_POST['add']) && is_array($_POST['add']))
{
$OK = true;
// make sure only numbers are included in the array
foreach ($_POST['add'] as $val) {
if (!is_numeric($val)) {
$OK = false;
}
}
// flatten array
if ($OK) {
$jobs = implode(',', $_POST['add']);
} else {
$jobs = 0;
}
}
You can then use $jobs safely in a SQL query:
$sql = "SELECT * FROM jobs WHERE job_id IN($jobs)";
--
David Powers, Adobe Community Expert
Author, "The Essential Guide to Dreamweaver CS4",
"PHP Solutions" & "PHP Object-Oriented Solutions"
http://foundationphp.com/