The goal is to get four values from four columns of the same row. But How can I print them in a random order? For example, everytime the page is refreshed, the order has to change.
$sql = mysql_query("SELECT DISTINCT a, b, c, d FROM them WHERE nr='1' ORDER BY RAND() DESC LIMIT 0,4");
while ($items = mysql_fetch_array($sql))
{
echo "$items[0]";
}
RAND() funtion is function where you can get random datas from ur database...now mate u can have that idea ..i use While loop
or
$sql = mysql_query("SELECT DISTINCT id, column, etc FROM them WHERE nr='1' ORDER BY RAND() DESC LIMIT 0,4");
while ($items = mysql_fetch_array($sql))
{
There would be 24 different ways if you hard coded this (im guessing its for a multiple choice question thing)
I would Use Something on the lines of this:
$all = mysql_fetch_array(mysql_query("SELECT a, b, c, d FROM them WHERE nr='1' "));
$rand = array_rand($all, 4);
print $all[$rand[0]]."<br/>";
print $all[$rand[1]]."<br/>";
print $all[$rand[2]]."<br/>";
print $all[$rand[3]]."<br/>";