I need to generate no in serial order starts from custom code. If user want to print two book with 3 receipt in each book and 2 coupon in each receipt.
user enter book code and total book
user enter receipt code and total receipt
user enter coupon code and total coupon
User input in textbox like:
bookno - 101
totalbook - 2
receiptno - 500
totalrec - 2
coupon - 700
totalcoup - 2
then output comes like below table.
In this table, coupon no are always unique.and receipt no comes twice because each receipt has two coupon alloted.
Please suggest me how generate below output using for loop and insert every row in database.
book receipt coupon
101 500 - 700
101 500 - 701
101 - 501 - 702
101 - 501 - 703
102 - 502 - 704
102 - 502 - 705
102 - 503 - 706
102 - 503 - 707
i try below code but not working properly.
$bookno= $_POST['bookcode'];
$totalbook= $_POST['book_no2'];
$receiptno = $_POST['receiptcode'];
$totalrec= $_POST['receipt_no'];
$couponno= $_POST['couponcode'];
$totalcoup= $_POST['coupon'];
for($row1=$bookno;$row1<=$bookno+$totalbook;$row1++)
{
for($row=$receiptno;$row<=$receiptno+$totalrec;$row++)
{
for($row2=$couponno;$row2<=$couponno+$totalcoup;$row2++)
{
$insertrow = $database->insertRow("INSERT INTO scheme_master (book_no2,receipt_no,coupon)
VALUES (:book_no2,:receipt_no,:coupon)",
array(':receipt_no'=>$row,':book_no2'=>$row1,':coupon'=>$row2));
}
}
}