Hi, I want this to display 4 usernames from 4 different rows in a table... I thought $query = ("SELECT * FROM `Queue` LIMIT 4"); $result = mysql_query($query); while ($row = mysql_fetch_array($result)) { $usernameone = $row['Username']; $usernametwo = $row['Username']; $usernamethree = $row['Username']; $usernamefour = $row['Username']; echo $usernameone. $usernametwo. $usernamethree. $usernamefour; } Would do it, but it doesn't work.. Does anyone how a way to do what i want? Or a way to fix the code above? Thanks alot, James
I have found a way, but it is really ineffective/inefficient way, so does anyone know a better way? -My way does... $query = ("SELECT * FROM `Queue` LIMIT 4"); $result = mysql_query($query); $row = mysql_fetch_array($result); $usernameone = $row['Username']; echo $usernameone; $query = ("SELECT * FROM `Queue` LIMIT 1, 3"); $result = mysql_query($query); $row = mysql_fetch_array($result); $usernametwo = $row['Username']; echo $usernametwo; and then two times more (typing it now)
1. Your query didn't use LIMIT correctly. 2. You thought the usernames would be returned all at once in your loop. If you just want to display them this is how you would do it: $query = ("SELECT * FROM `Queue` LIMIT 0,4"); $result = mysql_query($query); while ($row = mysql_fetch_array($result)) echo $row['Username']."<br>"; PHP: If you needed to use them later on the page you should replace the echo statement inside the while loop with an array and dump them there for use later.