Forums

How do I create a counter in my form?

sveingustavsen 21 Jul, 2008
I want to use a form as a work order - how do I add a counter that adds a work order number for each time someone uses the form?

I want to start counting on 0001, and next time someone use the form, they will get number 0002 in their form (this to keep track on the orders I get, as a reference)

In advance, thanks for all replys🙂
GreyHead 21 Jul, 2008
Hi sveingustavsen,

You'll need to store the last counter value somewhere. There are various ways of doing this but the simplest is probably to save the order data into the database and use an autoindexed field there to create sequential values.

There are a couple of examples of this in the forums here if I remember correctly. Search for 'insertid'.

Bob
sveingustavsen 06 Aug, 2008
Hi,

thanks for a quick response - and im sorry for my late answer.

I have been searching the forum but don't find any good solutions. I've tried different ways, but dont get what I want :/

I want my form go generate a service request number (unique) each time a form is sent to me. If someone can show me some direct code for this, or a link to a post that can help me, I would be very grateful.
GreyHead 06 Aug, 2008
Hi sveingustavsen,

Here's a link to the Joomla doumentation for $database->insertid() which will give you the id of the last record inserted in your databse table.

Bob
jmhuston14 08 Feb, 2009
How can be it explained for someone who dont have a big understanding about it...
Max_admin 08 Feb, 2009
Hi jmhuston14,

if you create a table using Chronoforms for your form then the field cf_id automatically auto incrementing with every record, this doesn't fit what you need ?

Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
This topic is locked and no more replies can be posted.