开发者

Echo DB columns randomly in a sequence

I'm trying to create lines of text from every row in a database. I would like to have the sequence of the columns to be random for every row i display.

The normal ech开发者_如何转开发o would be:

while($row = mysql_fetch_array($result)) {

 echo "{$row['Color']} {$row['Size']} {$row['Category']} <br>";
}

How I turn this into a random order for every line? I tried with the rand, the array_rand and the shuffle, but none of them seem to output the right in combination with the while function.


while($row = mysql_fetch_array($result, MYSQL_NUM)) {
   shuffle($row);
   echo implode(' ', $row).'<br />';
}


Sorry i'm not sure i can get what you mean with what youv'e asked, can you please add some examples of what you're after.

Ideally an array with the info ( could be fake ) and an example of the output you want. Doesnt have to be HTML, can simply be a comma seperated list.

Without that i'd be guessing.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜