473,403 Members | 2,359 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,403 software developers and data experts.

how to create a text box that generates auto number

hi , im a new in php. id like to know how to create a textbox that generates auto number for every new record to be inserted.

thanks
Feb 28 '07 #1
4 7734
snapple
11
you are a little vauge but I believe all you need is a counter.

say $count=0 then when you need a new text file, say $count++

This probably isn't what you are actually asking for, but i'm a little confused on your question.
Feb 28 '07 #2
ronverdonk
4,258 Expert 4TB
What "record to be inserted" are you talking about?
A database, a text file, ???

Ronald :cool:
Feb 28 '07 #3
You do not need to do this. When you insert the record, the database will automatically generate the autonumber required and report it back to you. It is much easier to report this information AFTER the insert has been done.

If you want to report it before the insert, then you actually have to insert a blank record to 'reserve' the autonumber. Without the proper care, this leaves blank records, incomplete data, or non-sequential records in your database. In other words, you can get the autonumber before inserting, but you have to make sure you are managing it correctly.
Feb 28 '07 #4
ronverdonk
4,258 Expert 4TB
If you want to know the next insert id before having done the actual insert, use MySQL's own table status and try the following code:
[php]<?
$tablename = "tablename";
$next_increment = 0;
$qShowStatus = "SHOW TABLE STATUS LIKE '$tablename'";
$qShowStatusResult = mysql_query($qShowStatus) or die ( "Query failed: " . mysql_error() . "<br/>" . $qShowStatus );

$row = mysql_fetch_assoc($qShowStatusResult);
$next_increment = $row['Auto_increment'];

echo "next increment number: [$next_increment]";
?> [/php]

Ronald :cool:
Feb 28 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: dog | last post by:
I've seen plenty of articles on this topic but none of them have been able to solve my problem. I am working with an Access 97 database on an NT4.0 machine, which has many Access reports. I...
24
by: flkeyman | last post by:
Work in legal office. Trying to create solid designed database structure. This is list of tables w/fields and primary keys. Any comments/advice greatly appreciated. tbl-Defendants CaseNumber...
2
by: macca | last post by:
Hi, I am writing a GUI application. It will have a number of user defined controls( I plan to use/create a user defined control that will output alarm states that the user can also select and...
6
by: windandwaves | last post by:
Hi Folk Some of my clients asked me to create "fancy emails" for them (aka html formatted emails). I know how to make a nice html document, but I had trouble creating a simple way to provide...
5
by: jdvon | last post by:
So I have downloaded this neat expression for a textbox control in a form that generates automatic sequence numbers with the 2-digit year in front of it: =Format(Now(),"yy") & "CAR" & "-" &...
8
by: Ornette | last post by:
Hello, I have a stored procedure which generates some values in the table. When I use update() how to populate the dataset with theses values ? For the moment I use output parameter but it...
2
by: markcarroll | last post by:
My company has a database on SQL server. I am tyring to make an access interface that will make a lot of things easier. I cannot change the database structure or the field types. I am trying to...
2
by: infosyed | last post by:
Hai I am doing project in C#.Net. i want to know how to create the Auto Generation Number in Text Box. I want store that number in Sql Database also. Anyone can help me. Advance Thanks for Your...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
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...
0
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...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.