943,816 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Marked Solved
  • Views: 3859
  • PHP RSS
Mar 28th, 2008
0

Select random database value?

Expand Post »
I m working on advertise website for that i need to select random values from the database
so please help me

Thanx in advance
Similar Threads
Reputation Points: 15
Solved Threads: 21
Posting Whiz in Training
nikesh.yadav is offline Offline
219 posts
since Feb 2008
Mar 28th, 2008
0

Re: Select random database value?

i Got the result myself and answer is

sql Syntax (Toggle Plain Text)
  1. SELECT * FROM tablename ORDER BY RAND() LIMIT 0,30

bye
Last edited by peter_budo; Mar 30th, 2008 at 5:46 am. Reason: Keep It Organized - please use [code] tags
Reputation Points: 15
Solved Threads: 21
Posting Whiz in Training
nikesh.yadav is offline Offline
219 posts
since Feb 2008
Apr 8th, 2010
-1
Re: Select random database value?
i Got the result myself and answer is

sql Syntax (Toggle Plain Text)
  1. SELECT * FROM tablename ORDER BY RAND() LIMIT 0,30

bye
Hey thanks allot for the information... just have a small question about the 0,30 numbers in the code, those mean how many units of data will choose¿¿
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Vledic is offline Offline
1 posts
since Apr 2010
Jun 30th, 2010
0

this is very usefull rand try it

<?php
ob_start();
include("conn.php"); //connection file
$sql = "select* from tablename order by rand()"; (rand is function of php not a field)
$query = mysql_query($sql);
$data = mysql_fetch_array($query);

?>

<?php echo $data['m'];?> ( m is field name )

thanks
Reputation Points: 10
Solved Threads: 0
Newbie Poster
anupam294 is offline Offline
1 posts
since Jun 2010

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: selecting a coulmn from table
Next Thread in PHP Forum Timeline: Join query





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC