Please am creating a wap forum and I want the admin to be able to add bbcodes from database named mycodes with columns: id, name, code, html

```
Row1
Name: bold
Code: \[b\](.*?)\[/b]
Html: < b >$1< / b >

Row2
Name: undaline
Code: \[u\](.*?)\[/u]
Html: < u >$1< / u >

```

When I use preg replace it worked only when I have one row, if I have more than one it won't work, it would only parse bold but not underline?

```
function myparse($text){
  $q = mysql_query("SELECT * FROM mycodes");
  while($row = mysql_fetch_array($q)) {
    $code=$row['code'];
    $html=$row['html']
    $Result=preg_replace('#'.$code.'#is', $html, $text);
    return $result;
  }
}

myparse("hey am [b]bold[/b] but he is [u]undalined[/u]");

```