i'm looking for a way to loop through the database and shows results in a html page, i'm actually creating a sorta fake email system for a little project.

so i have a table name "SENDS" with 5 columns ID, Mailtext, Touser, Subject, Fromuser.
what i wanna do is when user log in system connects to the database and select everything
from SENDS where touser='$email' -$email is defined when user logs in- and display it in a html div

```html
<div class="oubx">
  <div class="inbx">
   <span class="from"></span>
   <span class="subject"></span>
   <span class="mailtext"></span>
  </div>
 </div>
```

```css
.oubx {
 height:27px; width:800px;
 border:1px solid black;
 margin-top:;
 margin-left:80px;
 float:left;
 background-color:white;
}

.inbx {
 height:22px; width:700px;
 border:1px solid black;
 margin-top:1px;
 margin-left:45px;
 background-color:white;
 font-family:sans-serif;
 font-weight:bold;
 font-size:16px;
 color:#808080;
 float:left;
}
```

from of course tells whos it from

subject is subject

mailtext is what the mail is (it's hidden of course jQ will take care of it once clicked)

i have used mysqli\_num\_rows, mysqli\_fetch\_array, for loops, foreach etc but i just can't seem to get my head around it i'm having a hard time figuring out how to do it setp by steps or what the step is. please help :) thanks.

```html
$connectDB = mysqli_connect("host","root","","db");

$touser = mysqli_query($connectDB, "select * from sends where touser='$email'");
$to_numrows = mysqli_num_rows($touser);
$to_fetch = mysqli_fetch_array($touser);

//printing of html code = how many rows  
$ib = '<div class="oubx"><div class="inbx"><span class="from">'.$value.'</span><span class="subject">'.$value.'</span></div></div>';
for ($i = 0; $i < $to_numrows; $i++) {
 echo $ib;
}
```

the rest is work in progress..