@ rubberman, creating new table each day is not possible, because the users can book the ticket until 9 am. Also daily booking report will get generated at this time.

@pty, I can't use auto increment for BARCODE_SLNO because it should start from 1 on each day.

I'm trying to generate barcode tickets after successful booking and it's working fine. But yesterday (08-Jan-2017) night at 11.59 pm, one customer booked 2 tickets but the ticket sl.no was duplicate. Tthat is both tickets sl.no was 1. Actually it should be 2. But the next customer's tickets sl.no was correct, it's 3,4,5. Is there any mistake in the code below where the tickets get generated?

for($j=1;$j<=$cat_array[$i];$j++) {
  $sel_max_dt =  mysql_query("select MAX(DT) AS maxdt, MAX(REC_NO) AS maxrec FROM  tkt_barcode");
  //to select max date and max rec no.
  $row_max_dt = mysql_fetch_array($sel_max_dt);
  $dt_max = $row_max_dt['maxdt'];
  //$no_max = $row_max_dt['maxno'];
  $recno = $row_max_dt['maxrec'];
  if($dt_max ==  date("Y-m-d") && $recno == $TxnID) {
    //if same date and same bkid  barcode slno continues.
    $sel_no = mysql_query("select MAX(BARCODE_SLNO) AS maxno FROM  tkt_barcode WHERE REC_NO=".$TxnID);
    $row_sel_no = mysql_fetch_array($sel_no);   
    $tkt_slno = $row_sel_no['maxno'];
    $tkt_slno = $tkt_slno + 1;
  if($dt_max ==  date("Y-m-d")&& $recno != $TxnID) {
    //if same date and different bkid  barcode slno continues.
    $sel_no = mysql_query("select MAX(BARCODE_SLNO) AS maxno FROM  tkt_barcode WHERE DT='$dt_max' ");
    $row_sel_no = mysql_fetch_array($sel_no);   
    $tkt_slno = $row_sel_no['maxno'];
    $tkt_slno = $tkt_slno + 1;
  if($dt_max != date("Y-m-d") && $recno != $TxnID) {
    //if not same date start barcode slno from 1.
    $tkt_slno = 1;
  $sel_sl_no = mysql_query("select MAX(SL_NO) AS slno FROM  tkt_barcode WHERE REC_NO=".$TxnID);
  $row_slno = mysql_fetch_array($sel_sl_no);
  $slno = $row_slno['slno'];
  $bartkt_slno = $slno + 1;
  if($i==1 && $j>$count_promo_adult && $arr_edit["PROMO_CODE"]!=""){
    //adult cat and total adult count > total promo adult count
    $disc_adult = $adult_amt;
    $discamt=$adult_amt - $disc_adult ; //  discount amt
    $rate=$adult_amt;  //normal rate
    $net_amt=$disc_adult; //discount ...

hi ItsMe5247..
pls try this

$num =1;
$sql = "SELECT pp_number,Nationality,employer_id FROM `submission_form`";
$result = $database->query($sql);
while($row = $database->fetch_array($result)){
<div id=form_group<?php echo $num; ?>>
<input type="text" value="<?php echo $row['pp_number']; ?>" class="pp_number" />
<input type="text" value="<?php echo $row['Nationality']; ?>" class="nationlity" />
<input type="text" value="<?php echo $row['employer_id']; ?>" class="registry_number" />
<?php $num++; } ?>

oh sry.... @pritaeas its my mistake... now i changed it to this....

SELECT * FROM `tbl_product` WHERE FIND_IN_SET(prod_id,'101,102,103')

and its working fine now.....
tnx 4 ur reply pritaeas....

i tried this in one

SELECT * FROM `tbl_product` WHERE FIND_IN_SET('101,102,103',prod_id)

but result is... MySQL returned an empty result set (i.e. zero rows).

@pritaeas tnx 4 ur reply....
but here i have only one table named tbl_product, prod_id and related_id are also in this table.....
what i'm actually trying to do is... if i select product with prod_id=100 it should show the three related products with the prod_id 101,102,103

hi all pls help me....
im trying to select all related items of a particular product... related items are also another products...
here is an example of my table product...

   prod_id      related_id 
   100          101,102,103
   101          104,105   
   102          101,100
   103          100,101 
   104          103
   105          104

if i select product with prod_id = 100, it should select all related products from the table....
pls help me to fix this....
tnx in advnc...

pls remove the ";" this from


and try it again.....

@ tinabina22
pls try to use this http://codepad.org its an online compiler...
and here is your problem's solution http://codepad.org/7zpCmnoW
also pls check those things that ehpratah said like