title: function php with while loop
body: <p>Hello i am trying to make function with while loop in php but cant getting write here is my code </p>
  
  <pre><code> function mail_detail($mail_detail){
  
      $data= mysql_query("select * from messages where messages.to = '$mail_detail' and to_viewed = 0 ORDER BY messages.id DESC");
      while ($result= mysql_fetch_array($data)){
      return $result;
      }
  
  }
  </code></pre>
  
  <p>and out put is </p>
  
  <pre><code>$mail_detail= mail_detail($userid)
  echo '&lt;li class="read"&gt;
  
                 &lt;a href="#"&gt;
                   &lt;span class="message"&gt;'. $mail_detail['title'].'&lt;/span&gt;
                      &lt;span class="time"&gt;
                         January 21, 2012
                     &lt;/span&gt;
                                  &lt;/a&gt;
          &lt;/li&gt;';
  </code></pre>
  
  <p>i am not getting all values just getting one value please help
  thx</p>