2015-02-02 6 views
0

읽는 메시지가 정상적으로 표시되고 새 항목/메시지가 굵게 표시되는 전자 메일 방식 시스템을 만들려고합니다. 텍스트 서식을 충족시키는 CSS 규칙을 만들었지 만 문제는 루프에 구현하는 것입니다.새 항목을 굵게 표시합니다.

감사

아마 당신이 달성하지만, 적절한 질문을 다음 번에 문의하시기 바랍니다 원하는 무엇
 $stmt = $pdo->query("SELECT * FROM $tbl_name"); 
     $stmt->execute(); 
     $num_rows = $stmt->rowCount(); 
     print "<p>$num_rows Record(s) Found.</p>"; 

     echo "<table width='100%' border='1' bordercolor='#0cc' cellspacing='0' cellpadding='2'>"; 
     echo "<tr> 
     <th bgcolor='#444444' align='center'><font color='#fff'>Surname</font></th> 
     <th bgcolor='#444444' align='center'><font color='#fff'>Firstname</font></th> 
     <th bgcolor='#444444' align='center'><font color='#fff'>Email/Username</th> 
     <th bgcolor='#444444' align='center'><font color='#fff'>Phone</th> 
     <th bgcolor='#444444' align='center'><font color='#fff'>Date Registered</th> 
     <th bgcolor='#444444' align='center'><font color='#fff'>Status</th> 
     <th bgcolor='#444444' align='center'><font color='#fff'>Create Account</th> 
     <th bgcolor='#444444' align='center'><font color='#fff'>Delete Account</th> 
     </tr>"; 
     // keeps getting the next row until there are no more to get 
     while($row = $stmt->fetch(PDO::FETCH_ASSOC)) { 

     $clas = $row['entry']; 
     if($clas == 'NEW'){ 
     $style = "<div style='font-weight:bold'></div>"; 
     }else{ 
     $style = "<div style='font-weight:normal'></div>";  
     } 

     // Print out the contents of each row into a table 
     echo "<tr><td>"; 
     echo ucfirst($row['surname']); 
     echo "</td><td>"; 
     echo ucfirst($row['firstname']); 
     echo "</td><td>"; 
     echo $row['email']; 
     echo "</td><td>"; 
     echo $row['phone']; 
     echo "</td><td>"; 
     echo $row['today']; 
     echo "</td><td>"; 
     echo $row['status']; 
     echo "</td><td>"; 
     echo "<a href='create-account.php?id={$row['id']}'>Create Account</a>"; 
     echo "</td><td>"; 
     echo "<a href='account-delete.php?id={$row['email']}'>Delete Account</a>"; 
     echo "</td></tr>"; 
     } 
     echo "</table>"; 
+0

무엇이 문제입니까? 당신이 얻는 것은 무엇을 얻고 싶습니까? 빠른 시선에서 그것은 괜찮습니다. 그러나 나는 무엇을 찾아야할지 모릅니다. (나는 대답을 안다. 그러나 물어야한다. ..) – Forien

+0

어디에서 $ style를 사용 하느냐? –

+0

@Forien 질문을 잘못 읽어 죄송합니다. 내 코멘트를 삭제하겠습니다. –

답변

1

.

while($row = $stmt->fetch(PDO::FETCH_ASSOC)) { 

    $clas = $row['entry']; 
    if($clas == 'NEW'){ 
    $style = ' style="font-weight:bold"'; 
    } 

    // Print out the contents of each row into a table 
    echo "<tr{$style}><td>"; 
    echo ucfirst($row['surname']); 
    echo "</td><td>"; 
    echo ucfirst($row['firstname']); 
    echo "</td><td>"; 
    echo $row['email']; 
    echo "</td><td>"; 
    echo $row['phone']; 
    echo "</td><td>"; 
    echo $row['today']; 
    echo "</td><td>"; 
    echo $row['status']; 
    echo "</td><td>"; 
    echo "<a href='create-account.php?id={$row['id']}'>Create Account</a>"; 
    echo "</td><td>"; 
    echo "<a href='account-delete.php?id={$row['email']}'>Delete Account</a>"; 
    echo "</td></tr>"; 
} 
+0

감사하지만 의도 한대로 작동하지 않았습니다. 내가 원하는 것은 새로운 조건을 충족시키는 행에 대한 것이지만 대담 할 수는 있지만 조건에 관계없이 모두 굵게 표시됩니다. – Chidi

+0

감사합니다. 나는 그것을 마침내 얻었다. else 조건이 없으면 작동하지 않습니다. else 조건을 추가하면, 내가 원했던 부분이 다시 빠져 나옵니다. Ididnt는 스타일을 적용하는 방법을 알고있다. 그러나 지금 나는 방법을 알고있다. 미안하지만 당신이 부적절한 질문이라고 생각했다면,하지만 그렇게하기까지는 어려웠습니다! – Chidi

관련 문제