This PHP login script / tutorial will show you how you can have users register on your site, and log in to access secure areas. I have seen a few tutorials around the web which show how this can be done, but they all seem to lack in security. This user membership tutorial will show a better way of having users authenticated once logged in by using their session ID. Read the rest of this entry »
Posts Tagged ‘MySQL’
This is an update to a previous post of mine which uses the RAND() method. Using the following code, you can retrieve a random row much, much faster (MySQL 4.1.x/5.0.x), with thanks to Jan Kneschke:
SELECT <COLUMN> FROM <TABLE> AS r1 JOIN (SELECT ROUND( RAND( ) * ( SELECT MAX( id ) FROM <TABLE>) ) AS id ) AS r2 WHERE r1.id >= r2.id ORDER BY r1.id ASC LIMIT 1;
- <COLUMN> with the name of the column(s) you wish to retrieve
- <TABLE> with the name of the table you wish to retrieve the data from
I’ve tested this with a table with over 660,000 records, and got a response in 0.0200 seconds, whereas with ORDER BY RAND() i got a response in 2.1599 seconds.
Total Number of Rows: