profmysd
Posts: 3
|
| Posted: 07/12/2005, 11:57 PM |
|
Hello, I'm new to codecharge, php and mysql.
Really need help on how to auto generate a form number such as WR0001, WR0002 in code charge and it can be display on the new form each time?
Early reply needed, please help me??? Maybe sample of coding require from anyone?
_________________
profmysd |
 |
 |
peterr
Posts: 5971
|
| Posted: 07/13/2005, 12:52 AM |
|
See: http://us2.php.net/manual/en/function.rand.php http://www.google.com/search?
hl=en&q=php+generate+random+number
Once you find a code/function that you want to use, you can assign the random number to controls as shown at http://docs.codecharge.com/studio/html/ProgrammingTechn...ntrolValue.html
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com |
 |
 |
DonB
|
| Posted: 07/13/2005, 7:53 PM |
|
If you create a table with an auto_increment key, just do an insert on that
table and call mysql_insert_id() to find out the value it produced.
function GetSerial() {
$db = new clsDBConnection1; # Use the appropriate connection (I assumed
it's "Connection1")
$db->query("INSERT INTO <table>"); # finish defining the SQL to suit your
needs
$serialnumber = "WR" . mysql_last_id();
unset($db);
return $serialnumber;
}
--
DonB
http://www.gotodon.com/ccbth
"profmysd" <profmysd@forum.codecharge> wrote in message
news:542d4bb60f1ebd@news.codecharge.com...
> Hello, I'm new to codecharge, php and mysql.
>
> Really need help on how to auto generate a form number such as WR0001,
WR0002
> in code charge and it can be display on the new form each time?
>
> Early reply needed, please help me??? Maybe sample of coding require from
> anyone?
>
> 
> _________________
> profmysd
> ---------------------------------------
> Sent from YesSoftware forum
> http://forums.codecharge.com/
>
|
|
|
 |
Graham Pearson
|
| Posted: 07/14/2005, 3:29 PM |
|
Would you know what the last Form Number would be, and if so you can do
a select statement to get the last form number used then add 1 to it
before you displayed the new form number.
profmysd wrote:
> Hello, I'm new to codecharge, php and mysql.
>
> Really need help on how to auto generate a form number such as WR0001, WR0002
> in code charge and it can be display on the new form each time?
>
> Early reply needed, please help me??? Maybe sample of coding require from
> anyone?
>
> 
> _________________
> profmysd
> ---------------------------------------
> Sent from YesSoftware forum
> http://forums.codecharge.com/
>
|
|
|
 |
wkempees
|
| Posted: 07/14/2005, 4:04 PM |
|
Further to Grahams suggestion:
Select MAX(id) + 1 from table
would do the trick.
Then presenting it to the user to add details and submit would cause
duplicates, if another user would do the same at the same time.
If you go this route then you have to Select, add 1, insert and then
retreive the record for update, your user would then not be in insert
but edit mode.
Works fine as long as there are no required field in the table other
than the PK, would otherwise reject the insert.
|
|
|
 |
wkempees
|
| Posted: 07/14/2005, 4:10 PM |
|
Afterthought:
Why not let your user fill out all details in the record and then on
Submit, calculate the next WRnumber, present the user with a sort of
confirmation page/message :
Your request has been filed as WRnnn
Displaying the WRnumber you just updated in (a separate) table.
|
|
|
 |
|