Help - Search - Members - Calendar
Full Version: how to generate 000001,000002,000003....and so on and i want to insert into database
Pixel2Life Forum > Help Section > PHP, ASP, MySQL, JavaScript and other Web/Database Programming Help
uy_cortz
how to generate 000001,000002,000003....and so on
and i want to insert into database

anybody here to help me..i don't no if my code is correct...thank you...

here my code:
CODE
$query_all = "Select BranchAcct, AcctNum, Type_Entry, DateOpen, FirstName, MidName, LastName, Address, TelNum, Amount from raffle ";
$result_all = mysql_query($query_all);
// read the first record
if( $rs = mysql_fetch_row( $result_all ) ){
   // do something with this record
   $BA = $rs[0];
   $AN = $rs[1];
   $TE = $rs[2];
   $DO = $rs[3];
   $FN = $rs[4];
   $MN = $rs[5];
   $LN = $rs[6];
   $AD = $rs[7];
   $TN = $rs[8];
   $AMT = $rs[9];
  

}

// do another stuff here
  $TicketNo =1;
  //$ticket_view = sprintf("%06d", $TicketNo);
//  echo $ticket_view;
  $NoOfTickets = $AMT % 100000;

       for ($i=1; $i<=$NoOfTickets; $i++){
        
         $query_ins = "INSERT INTO tmptable (TicketNum, BranchAcct, AcctNum, Type_Entry, DateOpen, FirstName, MidName, LastName, Address, TelNum, Amount) VALUES ('$TicketNo', '$BA', '$AN', '$TE', '$DO', '$FN', '$MN', '$LN', '$AD', '$TN', '$AMT')";
         $result_ins = mysql_query($query_ins);
        
         $TicketNo = $TicketNo + 1;
       }

// keep reading till the end
if( mysql_num_rows( $result_all )>1 ){
   do{
      // processing the records till the end
  $TicketNo = 1;
  //$ticket_view = sprintf("06d", $TicketNo);
  $NoOfTickets = $AMT % 100000;

       for ($i=1; $i<=$NoOfTickets; $i++){
        
         $query_ins = "INSERT INTO tmptable (TicketNum, BranchAcct, AcctNum, Type_Entry, DateOpen, FirstName, MidName, LastName, Address, TelNum, Amount) VALUES ('$TicketNo', '$BA', '$AN', '$TE', '$DO', '$FN', '$MN', '$LN', '$AD', '$TN', '$AMT')";
         $result_ins = mysql_query($query_ins);
         $TicketNo = $TicketNo + 1;
       }

   }while( $rs = mysql_fetch_row( $result_all ));

}
rc69
Moved to proper forum and added [ code ] tags around the php.

QUOTE
how to generate 000001,000002,000003....and so on
and i want to insert into database

You'll need to be more specific than that. I see nothing in your code that relates to the generation of "000001,000002,000003..." Could you possibly describe what you are attempting to do?
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2009 Invision Power Services, Inc.