KaiSheng Posted November 12, 2013 Share Posted November 12, 2013 (edited) rand(0,100) will not work in my case. I am trying to get a string not integer. Problem : I want to get 1 username of all username in my database. (randomed ones) Anyone know of this? mind helping me? --- code -- $query = "SELECT id,email from users"; $result = mysqli_query($link, $query) or die('error query'); while ($row = mysqli_fetch_array($result)) { $id = $row['id']; $username = $row['username']; echo '$username'; This gives all username, but i only want 1 randomed one. which part of code do i add on? Edited November 12, 2013 by KaiSheng Quote Link to comment Share on other sites More sharing options...
Solution KaiSheng Posted November 12, 2013 Author Solution Share Posted November 12, 2013 i got it. i did this. $query = "SELECT id,email from users ORDER BY RAND() LIMIT 1"; Thanks for whoever taking their time to read /Thread solved. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.