10个随机的mySQL行到不同的行

Basically, I'm trying to get 10 random rows from MySQL and put them in my page. Getting those 10 random rows is easy. The code that i have is:

$r = mysql_query("SELECT * FROM email order by rand()limit 10") 
or die(mysql_error()); 
while($row = mysql_fetch_assoc($r))
{
 echo $row['Email'];
}

Now, echo gets those 10 rows and shows them to me, but I need to separate them, so I can put them in my site, one per div or whatever. Can anyone tell me how to separate those emails so I can put each of them in the place I need?

$r = mysql_query("SELECT * FROM email order by rand()limit 10") 
or die(mysql_error()); 
while($row = mysql_fetch_assoc($r))
{
 echo "<div>";
 echo $row['Email'];
 echo "</div>";
 }

What I would do in this instance would be:

$r = mysql_query("SELECT * FROM email ORDER BY rand() LIMIT 10") 
or die(mysql_error()); 
$data = array();
while($row = mysql_fetch_assoc($r))
{
    $data[] = $row;
}

This will give you a array of random rows, You can then in your HTML do the following:

echo $data[0]['Email']; 

Replacing the ID of the array with what random record you want..

No idea why you want to do like that, it is a pretty bad design but however if that is what you want, all you have to do is:

$r = mysql_query("SELECT * FROM email order by rand()limit 10") 
or die(mysql_error()); 
while($row = mysql_fetch_assoc($r))
{
  $email[] = $row;
}

now you have an array called $email with 10 elements in it. You can use it so, replacing field_name with whatever your email fields are:

<div><?php echo $email[0]['field_name'];?></div>
<lots of other html tags>
<div><?php echo $email[1]['field_name'];?></div>
<yet again more html tags>
<div><?php echo $email[2]['field_name'];?></div>