hi all,
i am new to php.how to generate invoice number (EX:INV2008001) this format.
plz reply me the code....
thanks
palani
21 8518
Hi,
I can't spoonfeed you the code, but you'll want to have a look at rand as a start.
Should be pretty straight forward for you.
Hi,
I can't spoonfeed you the code, but you'll want to have a look at rand as a start.
Should be pretty straight forward for you.
That could produce a duplicate invoice number, though.
I think the best way would be to have an invoice number : INV20000001, and then increment that.
Save it in a db maybe.
That could produce a duplicate invoice number, though.
I think the best way would be to have an invoice number : INV20000001, and then increment that.
Save it in a db maybe.
Or use this...
[php]
$new_invoice = gettimeofday();
$new_invoice = $new_invoice[sec];
[/php]
This will help if the invoice is generated not too fast. (Not more than once in a sceond)
That's true, as you say you should have a combination.
My post was a bit clumsy, thanks for pointing it out.
Or use this...
[php]
$new_invoice = gettimeofday();
$new_invoice = $new_invoice[sec];
[/php]
This will help if the invoice is generated not too fast. (Not more than once in a sceond)
But still, it's not relevant to the invoices..
You'd typically (or is it just me) want to be able to keep track of the amount of invoices sent.. and don't invoice numbers generally go up as they are a way of tracking someone?
But still, it's not relevant to the invoices..
You'd typically (or is it just me) want to be able to keep track of the amount of invoices sent.. and don't invoice numbers generally go up as they are a way of tracking someone?
Yeah, that will only help if you have to keep them unique. Not a counting of all.
But with this there is no db query required.
Or one other option can be...
- make a file with 0 written inside it.
- every time you create a new invoice, read that file and create the invoice like : [php]
//$file_content = content of the saved file
$invoice = "INV";
for ($i = 0; $i<10 - strlen($file_content); i++)
$invoice .= "0";
$invoice .= $file_content;
$file_content++;
//then save $file_content to the same file.
[/php]
I catch dig your jammin!
But, ultimately, it is better to use a database to keep track of records.
Look at us, i bet the OP has forgotten about this thread..
I catch dig your jammin!
But, ultimately, it is better to use a database to keep track of records.
Look at us, i bet the OP has forgotten about this thread..
Yeh you are right in both the things...
1. Its better to use db, coz you might need to keep some other info about the invoice.. eg.. date, time, customer etc.
2. OP has forgotten about the thread.
Good discussion though. How about using database table attributes:
INT(5) ZEROFILL AUTO_INCREMENT ? That way everytime a row is added it will increase by one but will appear as 00001 then 00002 etc...
Good idea/bad idea? I ask cos this is how I plan to set my system up.
Good discussion though. How about using database table attributes:
INT(5) ZEROFILL AUTO_INCREMENT ? That way everytime a row is added it will increase by one but will appear as 00001 then 00002 etc...
Good idea/bad idea? I ask cos this is how I plan to set my system up.
Nothing wrong with the idea in itself, BUT ... never reorganize that table because your run the risk that it will be renumbered (assuming you sometimes delete rows from the table).
Ronald
Nothing wrong with the idea in itself, BUT ... never reorganize that table because your run the risk that it will be renumbered (assuming you sometimes delete rows from the table).
Ronald
OK a little confused by what you mean. If i make a table:
00001 John
00002 Zed
00003 Adam
Then delete Row 2 (Zed). The next time I INSERT a row it will become:
00001 John
00003 Adam
00004 Tom
No repeat?
If I order by alphabetical order:
00003 Adam
00001 John
00004 Tom
Then INSERT a new row, I think it will be:
00003 Adam
00001 John
00004 Tom
00005 Wayne
Let me know if I am wrong, and also let me know if this is not what you meant. Thanks for your input!
Good discussion though. How about using database table attributes:
INT(5) ZEROFILL AUTO_INCREMENT ? That way everytime a row is added it will increase by one but will appear as 00001 then 00002 etc...
Good idea/bad idea? I ask cos this is how I plan to set my system up.
I like, and i didn't know about the ZEROFILL!
So it shall now be with me on my travels!
I like, and i didn't know about the ZEROFILL!
So it shall now be with me on my travels!
w00t! I actually knew something someone didn't know! No offense markusn00b, u have already taught me so much, I'm glad to contribute something useful!
w00t! I actually knew something someone didn't know! No offense markusn00b, u have already taught me so much, I'm glad to contribute something useful!
Well, well!
Student has become the teacher!
Anyway, Ronald, how about my question above?
Anyway, Ronald, how about my question above?
Sorry, I have been away for a day.
What I meant is that when you REORGANIZE your table all the auto_increment values are also reorganized. So your table - 00001 John
-
00003 Adam
-
00004 Tom
-
00005 Wayne
wll after the reorganize look: - 00001 John
-
00002 Adam
-
00003 Tom
-
00004 Wayne
But of course, if you never reorganize, that's fine. And if your auto_increment numbers do not represent values like an invoice number, fine. My remark was just a liitle warning.
Ronald
Sorry, I have been away for a day.
What I meant is that when you REORGANIZE your table all the auto_increment values are also reorganized. So your table - 00001 John
-
00003 Adam
-
00004 Tom
-
00005 Wayne
wll after the reorganize look: - 00001 John
-
00002 Adam
-
00003 Tom
-
00004 Wayne
But of course, if you never reorganize, that's fine. And if your auto_increment numbers do not represent values like an invoice number, fine. My remark was just a liitle warning.
Ronald
Fair enough. I think I am thinking of something different. When you say reorganise, do you mean ORDERBY or is there a REORGANISE function?
Fair enough. I think I am thinking of something different. When you say reorganise, do you mean ORDERBY or is there a REORGANISE function?
The original question in this thread was about invoices.
By reorganize I mean just a SELECT INSERT sequence wehereby you get rid of the holes in your table sequences. MySQL does not have a REORGANIZE function (yet).
Ronald
Sorry to go off topic a bit, but I think the OP has left:
If I have a hole and go INSERT, it shouldn't plug up the hole but continue the sequence. I have tried this before, so I guess I want to know how to plug that hole so I can avoid doing it!
Sorry to go off topic a bit, but I think the OP has left:
If I have a hole and go INSERT, it shouldn't plug up the hole but continue the sequence. I have tried this before, so I guess I want to know how to plug that hole so I can avoid doing it!
This goes beyond the thread problem. I will ans wer this and then close this discussion. I was not talking about a simple INSERT, but re-arranging the auto_increment index into a new table using INSERT SELECT...
People do that because they have a very heavily changing table and are afraid that the auto_increment index is running out. (an INT as key and a million changes per day can get you into such a situation).
Ronald
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Hohn Upshew |
last post by:
I have a rather complicated function for updating from a list box called
ListInvoices I want after updating to have a message saying " Invoice
number ... has been
updated."The invoice number...
|
by: David B |
last post by:
I am creating invoices for an app I am busy with.
The transactions for the invoice come from 2 tables which store Sales and
Facilities Hire.
The current arrangement is that I create a temp...
|
by: NomoreSpam4Me |
last post by:
Hi there i have a little problem with my invoice.
Here it is:
i have a main menu with buttons, one of my button is "Create new
invoice", when click on it a form pop up so i can enter my...
|
by: samdev |
last post by:
I need to set up invoices so each new invoice has next available number
assigned.
I have a table Named "InvoiceNumbers" that has a single field =
"nextnumber"
A 2nd table that contains the...
|
by: yellowarmy |
last post by:
Theres two problems i have.
1) Theres a question i have to answer in a mock is that the company does invoices every month but i need it for to select invoice and then select the month whcih would...
|
by: Kris |
last post by:
I need to create a valid mod10 or luhn number that can be attached to
an invoice, I have found several examples showing how to validate a
credit card number or validate a number using mod10/luhn.
...
|
by: eyalco |
last post by:
I'm building a receipt/invoice database - I've started with the invoice first, then the receipt.
I have invoice = parents and sons + receipt = parents and sons tables + a customer table.
I want to...
|
by: ConfusedMay |
last post by:
Hi I need some helps in calculating the invoice amount in access 2003 report. Basically I have an access report that shows invoice#, invoice amount, payment amount, and payment date. The problem is...
|
by: gazza10001 |
last post by:
Hi
i hope you can help my company uses access and has modified for its needs usually what happens is you serach for the invoice by its number and then it brings all the information up such as...
|
by: Coni |
last post by:
Hi All,
I am working in Access to print Invoices. On each invoice there is a line number column which is a field to number each line for a product purchase. I would like to know if there is a...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |