proč to nezkusit, před provedením dotazu zkontrolujte, zda je zaškrtnuté políčko
if(isset($_POST['Submit'])){
try{
$orderNo = $_SESSION['orderNo'];
$serviceTitle=$_POST['serviceTitle'];
$price= $_POST['price'];
$quantity= $_POST['quantity'];
$amount= $_POST['amount'];
for ($i=0; $i<count($serviceTitle); $i++){
if(!empty($_POST['checkbox'][$i])) {
$statement = $db->prepare("INSERT INTO invoice (orderNo,productName,price,quantity,amount) VALUES (?,?,?,?,?)");
$statement->execute(array($orderNo,$serviceTitle[$i],$price[$i],$quantity[$i],$amount[$i]));
}
}
header("location: order_confirm_tech_step1.php");
}
catch(Exception $e) {
$error_message = $e->getMessage();
}
}
Poznámka:name="checkbox[]"