What I Currently have
I have a table in a database where the primary key (ID) is numbers (1, 2, 3, 4...) and a form that users fill in to enter a record into the table. The primary key in the form is hidden and is automatically put in by adding one on to the total number of records.
<input name="id" type="hidden" value="<?php echo $totalRows_rstPhotos + 1 ?>" />
eg. I have a total of 14 records, the next ID would be 15.
But what if I had deleted one record (ID 8 ), the last ID was 14 but there are only 13 records (making the next 'auto' ID 14) creating a duplicate ID
What I Want to do is...
I could do with an example of an SQL query of piece of PHP code that would get the highest value in the ID column. As '$totalRows_' gets the total number of rows in the table (or results in the query), is there something that gets the highest value in the column.
eg. a column consists of...
1
2
5
6
7
9
10
12
18
There are 9 rows ('$totalRows_rstPhotos + 1' would = 9). But the highest value is 18 ('$SomeCode_rstPhotos + 1' would = 19).
Is there any piece of code to do this.
Any help would be very much appreciated!
Thank You!
I have a table in a database where the primary key (ID) is numbers (1, 2, 3, 4...) and a form that users fill in to enter a record into the table. The primary key in the form is hidden and is automatically put in by adding one on to the total number of records.
<input name="id" type="hidden" value="<?php echo $totalRows_rstPhotos + 1 ?>" />
eg. I have a total of 14 records, the next ID would be 15.
But what if I had deleted one record (ID 8 ), the last ID was 14 but there are only 13 records (making the next 'auto' ID 14) creating a duplicate ID
What I Want to do is...
I could do with an example of an SQL query of piece of PHP code that would get the highest value in the ID column. As '$totalRows_' gets the total number of rows in the table (or results in the query), is there something that gets the highest value in the column.
eg. a column consists of...
1
2
5
6
7
9
10
12
18
There are 9 rows ('$totalRows_rstPhotos + 1' would = 9). But the highest value is 18 ('$SomeCode_rstPhotos + 1' would = 19).
Is there any piece of code to do this.
Any help would be very much appreciated!
Thank You!
