
March 16th, 2004, 07:10 PM
|
|
Registered User
|
|
Join Date: Apr 2007
Posts: 22,309
Time spent in forums: < 1 sec
Reputation Power: 24
|
|
|
Selecting Random Database Item
I am trying to write a script that will connect to my MySQL Database and select a random entry in a table and then print it to the screen.
Here is the my database table setup
php Code:
Original
- php Code |
|
|
|
`id` int(11) NOT NULL default '0', `name` varchar(40) NOT NULL default '', `description` text NOT NULL, `upright` text NOT NULL, `reversed` text NOT NULL, `image` varchar(40) NOT NULL default '', `uthumb` varchar(40) NOT NULL default '', `rthumb` varchar(40) NOT NULL default '',
Here is my script code
php Code:
Original
- php Code |
|
|
|
I need the script to connect to the listing database and randomly select an entry from id table and print it in the script. Each entry has information like this..
php Code:
Original
- php Code |
|
|
|
INSERT INTO `database name` VALUES (1, 'text description 1 rn', 'text description 2 rn', 'text description 3', 'pic1.jpg', '/thumbs/pic1.gif', '/thumbs/pic1r.gif');
Ok for example my script connects to the database and I need it to randomly select 9 different entries. How do I have it to randomly select the 9 entries and echo them to the page?
Any Help is very much apperiated.
|