开发者

PHP loop through query, first row

开发者 https://www.devze.com 2023-02-05 09:29 出处:网络
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:

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 开发者_StackOverflow中文版= 1)
   {
       echo "<script type='text/javascript'>newestid=".$row['id']."</script>";
$i = 2;
    }
}


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

if ($i == 1)
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号