the while loop is this creates so many of them it crashes my browser what is wrong with the code?

<?php

$template = "<a name=\"topic-{ID}\"></a><h2><a href=\"#\">{TITLE}</a></h2><p class=\"post-by\">{CONTENT}</p><p class=\"post-footer align-left\"><a href=\"index.php\" class=\"readmore\">Posted {DATE_POSTED}</a><br /></p>";

$sql = "SELECT * FROM `news` LIMIT 3";
$result = @mysqli_query($cxn, $sql) or print("No Posts Found.");
while($row = mysqli_num_rows($result)){
$temp = str_replace("{TITLE}", $row['title'], $template);
$temp = str_replace("{DATE_POSTED}", $row['datePosted'], $temp);
$temp = str_replace("{ID}", $row['id'], $temp);
$temp = str_replace("{CONTENT}", $row['content'], $temp);
echo $temp;
}

?>

    If mysqli_num_rows($result) returns a non-zero (i.e., the result set is not empty), the loop will loop forever since it will always return a non-zero, which is then evaluated as true. You probably want to fetch the row instead.

      I'm pretty sure where you wrote this:
      while($row = mysqli_num_rows($result)){
      you mean this:
      while($row = mysqli_fetch_assoc($result)){

        Write a Reply...