# Looping

**URL:** <https://forum.kirupa.com/t/looping/225724>\
**Category:** Uncategorized\
**Created:** [May 15, 2007, 6:08am UTC](https://forum.kirupa.com/t/looping/225724 "2007-05-15T06:08:39Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![james182](https://avatars.discourse-cdn.com/v4/letter/j/278dde/32.png) [@james182](https://forum.kirupa.com/u/james182)\
**Post date:** [May 15, 2007, 6:08am UTC](https://forum.kirupa.com/t/looping/225724/1 "2007-05-15T06:08:39Z")

</div>

How can i get this to loop properly?

```php

<?php
include 'connect.php'; 
                
                $result = mysql_query("SELECT * FROM Table "); 
                $i = 0;
                while($r=mysql_fetch_array($result)){
                    $title=$r["title"];
                    $testimonial=$r["testimonial"];
                    $id=$r["id"];
                
?>

<?php
                function $i format_html($testimonial){
                  $testimonial = "<p>" . str_replace("
", "<br/>", $testimonial) . "";
                  $testimonial = "" . str_replace("<br/><br/>", "</p><p>", $testimonial) . "";
                  $testimonial = "" . str_replace("**", "<img src='images/icon.gif' width='9' height='9' border='0'>", $testimonial) . "";
                  $testimonial = "" . str_replace("[pdf]", "<img src='images/icon_pdf.gif' width='20' height='20' border='0'>", $testimonial) . "";
                  $testimonial = "" . str_replace("---", "<div class='line' /><br /></div>", $testimonial) . "";
                  return "" . str_replace("<br/><li>", "<li>", $testimonial) . "";
                 }
                echo $i format_html("$testimonial");
                ?>
<?php
i++;
 } 
?>

```
