0

I'm trying to output something special with the first row but it seems to output on every row, here is the code im using:

$query = mysql_query("SELECT * FROM chat WHERE id > '".$_GET["latest"]."' ORDER BY id DESC LIMIT 0, 20");
$number = mysql_num_rows($query);
$i = 1;
while ($row = mysql_fetch_assoc($query)) {

echo "<div class='babble' style='width:130px;overflow:hidden;margin:auto;'><a href=\"javascript:ajaxpage('user_profile.php?game=1&ajax=1&user=".$row['author']."', 'content');\" style=\"cursor:pointer;\"><font color=#ff4355><b>".$row['author']."</b></font></a><font color=#ff4355>:</font></b> ".$row['babble']."</div>";
   if($i = 1)
   {
       echo "<script type='text/javascript'>newestid=".$row['id']."</script>";
$i = 2;
    }
}

1 Answer 1

7

You need to use the comparison operator ==, not the assignment operator = in your if statement.

if ($i == 1)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.