简体   繁体   中英

codeigniter auto incrementing ID that can be seen in view and Javascript Window.Print() function

so i am making an invoice, and I want that in my view, which is the receipt.php has an Invoice No: for example is 0001 and this is what will I put in my tbl_payment as the primary key, but how will I be able to have an auto incremented ID at the view when my table is still empty? and 2nd is I want to print it, BUT theres something wrong with my Window.Print() function, is that i am styling my receipt using CSS and eventhough how much I put effort into it, what I can only see is black and white, This is the one that you can see in the receipt

and this is what you can see when I print, how does this happen?

I got your point,here is one of the way to show Invoice No. There might be better approach but this is something came into my mind at first instance.

  1. Get the last invoice number from the database.(You can get MAX from the column)
  2. In your view increment the ID by 1(One).
  3. Show the incremented ID wherever you required.

Let me know your queries over this.

---- UPDATE ----

The best way or proper way is to get the invoice id only after creating the invoice.

If you go with above mentioned method you should do proper locking of database to avoid any duplication of data.

So,to keep it simple you should use invoice_id after insertion else another way would be to generate a unique id for invoice field irrespective of auto increment id.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM