note 44938 deleted from function.rand by tomsommer

From: Date: Fri, 20 Aug 2004 18:06:44 +0000
Subject: note 44938 deleted from function.rand by tomsommer
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-75010@lists.php.net to get a copy of this message
Note Submitter: boris_n at mail dot bg ---- to igge at netpound dot com If you have an auto_increment (id), but you delete entries from the table, you can do the following: SELECT COUNT(id) FROM <table_name> WHERE 1; Then you fetch the result to $entries, $rand = rand(0, $entries) and the take only one entry from the database: SELECT * FROM <table_name> WHERE 1 ORDER BY id LIMIT $rand, 1

« previous php.notes (#75010) next »