PHP Coding
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsPHP RelatedPHP Coding

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here
  #1  
Old May 31st, 2002, 05:19 AM
D1NGO D1NGO is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Perth, Australia
Posts: 221 D1NGO User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
RE: Random row

never mind, i figured it out...just had to lose a couple of ` things...

Reply With Quote
  #2  
Old May 31st, 2002, 10:59 AM
D1NGO D1NGO is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Perth, Australia
Posts: 221 D1NGO User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
Random row

Sorry, i know this is probably an easy question, but i'm not too familiar with SQL, but how do you select a random row from the database?

this is what i have so far
php Code:
Original - php Code
  1.  
  2. mysql_connect(HOST, USER, PASS) or die("Couldnt connect to database");
  3. mysql_select_db(DB) or die("Couldnt select database");
  4. $result = mysql_query("SELECT `quote` FROM `quotes` ORDER BY `rand()` LIMIT 1");
  5. $row = "mysql_fetch_array($result)";
  6.            
  7. echo "{$row['quote']}";


cheers

Reply With Quote
  #3  
Old July 29th, 2002, 03:20 PM
Anonymous Anonymous is offline
Registered User
Codewalkers God 35th Plane (22000 - 22499 posts)
 
Join Date: Apr 2007
Posts: 22,309 Anonymous User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 24
RE: Random row

Are you going to let us in on the answer?

Reply With Quote
  #4  
Old July 29th, 2002, 03:27 PM
Anonymous Anonymous is offline
Registered User
Codewalkers God 35th Plane (22000 - 22499 posts)
 
Join Date: Apr 2007
Posts: 22,309 Anonymous User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 24
RE: Random row

The easiest way to select a random row is just like :

SELECT * FROM table ORDER BY rand() LIMIT 1


Reply With Quote
  #5  
Old July 29th, 2002, 03:55 PM
D1NGO D1NGO is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Perth, Australia
Posts: 221 D1NGO User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
RE: Random row

thats exactly what i got it was a while ago but i think i just had to remove the backticks or something like that, nothing major

Reply With Quote
Reply

Viewing: Codewalkers ForumsPHP RelatedPHP Coding > Random row


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway