··조회 8,901
[re] while 관련
현재 그 값이 while문 속에 들어 있거던요..
$query="select * from 테이블명 by num desc";
$result=mysql_query($query);
while($row=mysql_fetch_array($result))
{
//---답변 주신 내용----
if($row[a]==$temp){
$row[a]="<font color='red'>$row[a]</font>";
}else{
$row[a]="$row[a]";
}
$temp=$row[a];
//-------------------
$auto=$total_record-$offset-$i;
$i++;
echo "<tr bgcolor='#FFFFFF'>
<td height='30' width='100'><p align='center'>$row[a]</p></td>
<td height='30' width='100'><p align='center'>$row[b]</p></td>
<td height='30' width='100'><p align='center'>$row[c]</p></td>
<td height='30' width='100'><p align='center'>$row[e]</p></td>
<td height='30' width='100'><p align='center'>$row[f]</p></td>
</tr>
";
}
$query="select * from 테이블명 by num desc";
$result=mysql_query($query);
while($row=mysql_fetch_array($result))
{
//---답변 주신 내용----
if($row[a]==$temp){
$row[a]="<font color='red'>$row[a]</font>";
}else{
$row[a]="$row[a]";
}
$temp=$row[a];
//-------------------
$auto=$total_record-$offset-$i;
$i++;
echo "<tr bgcolor='#FFFFFF'>
<td height='30' width='100'><p align='center'>$row[a]</p></td>
<td height='30' width='100'><p align='center'>$row[b]</p></td>
<td height='30' width='100'><p align='center'>$row[c]</p></td>
<td height='30' width='100'><p align='center'>$row[e]</p></td>
<td height='30' width='100'><p align='center'>$row[f]</p></td>
</tr>
";
}
댓글 1
$temp=$row[a];의 위치가 저기 있으면 안되겠네요.
if문이 참일 때와 거짓일 때 공히 첫째줄에 써주면 되겠네요.
아래와 같이요.
if($row[a]==$temp){
$temp=$row[a];
$row[a]="<font color='red'>$row[a]</font>";
}else{
$temp=$row[a];
$row[a]="$row[a]";
}
이렇게 하면 되겠네요.