Quantcast
Channel: PHP Freaks: PHP Help
Viewing all articles
Browse latest Browse all 13200

Finding the last row of the mysql table.

$
0
0

Hi all !

 

another simple mysql query to which i never found any satisfactory answer so far. 

 

I have a table with four fields. id is auto generated and increases as the table is filled. So i fill the table and say i have 4 entries in it as shown.

 

id         name          age      class    

1          aaa              6            1

2          bbb              6            1

3          ccc               7            2

4          ddd              7            2

 

Now i wish to add the 5th entry but before that i wish to query the database to find how many records have already been entered so far. So whats the best way to get that using php and mysql. i can count the number of rows or i can check for the last vale of id and from there i can know that the next row would be 5 and so would the id be. pls some appropriate code is what i am looking for. beginning wid connecting to the database. ( WHY? cos sql has a nasty habit of throwing Warnings which are difficult to get over) Thanks loads.

            


Viewing all articles
Browse latest Browse all 13200

Trending Articles