Jump to content

Random and get a name from db


KaiSheng

Recommended Posts

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?
Link to comment
https://forums.phpfreaks.com/topic/283832-random-and-get-a-name-from-db/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.