faqts : Computers : Programming : Languages : PHP : Database Backed Sites : General

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

12 of 16 people (75%) answered Yes
Recently 6 of 10 people (60%) answered Yes

Entry

How do i display the number of records on my main page without constantly quering mySQL? (eg. displaying the number of job postings are in mydatabase)

Jun 17th, 2000 06:48
Antonio Galea, Mark Andrews, Onno Benschop,


Since the number is going to change only with INSERT or DELETE
operations, you need to obtain the record count (with a query like
'SELECT COUNT(*) from _my_table_here_') from your table only after such
an event; when you do, save it into a file and read that file from your
home page (remember to lock file before writing!).
The count will be accurate only as long as you catch _all_ the
insert/delete operations on the table, though...