2010-08-16 2 views
1

는 현재 내 statusmessages를 표시하는이 가진 메신저 :PHP : 동안() 최신의 더 큰 글꼴 크기

<?php 
while($showSe = mysql_fetch_array($stringUSS)) { ?> 

    <strong style="font-size: 12px;"><?php get_day_name($showSe["date"]); get_time($showSe["date"]); ?> </strong><br> 
    <span style="font-size: 20px; text-align: center; margin: 10px;"><?php echo $showSe["status"]; ?></span> 
    <hr> 
<?php } ?> 

이제 ID로 데이터베이스 순서에서 모든 것을 표시합니다. 내가 지금하고 싶은 것은 첫 번째/가장 새로운 것, font-size : 18px; 나머지는 12px 있습니다.

답변

1
당신은 첫 번째 반복을 나타 내기 위해 카운터 또는 플래그를 사용할 수

:

$counter = 0; 
while ($showSe = mysql_fetch_array($stringUSS)) { 
    $fontSize = ($counter === 0) ? 18 : 12; 
?> 
<strong style="font-size: <?php echo $fontSize;?>px;"><?php get_day_name($showSe["date"]); get_time($showSe["date"]); ?> </strong><br> 
<span style="font-size: 20px; text-align: center; margin: 10px;"><?php echo $showSe["status"]; ?></span> 
<?php 
    $counter++; 
} 

또 다른 방법은 순수 CSS를 사용하는 것입니다 : 목록에서 (예를 들어 OL를) 항목을 넣고을 선택 ol > li:first-child > strong를 사용 첫 번째 LISTRONG 요소 :

ol > li > strong { 
    font-size: 12px; 
} 
ol > li:first-child > strong { 
    font-size: 18px; 
} 
+0

아니면 그냥 루프 밖에'$ 글꼴 크기 = 18'을 한 다음 첫 번째 결과 행이 출력되었습니다 후 (12)으로 재설정 할 수있다. 그러나 OP가 복수의 '첫 번째'줄을 결정할 때 embigenation 처리가 필요한 경우 카운터를 사용하면 더욱 유연 해집니다. –