2011-10-24 2 views
1

PHP 결과에서 5 개의 열을 반환하는 스크립트가 있습니다. 기한 날짜와 현재 날짜 중 하나를 일치 시키려고합니다. 반환 된 날짜가 오래된 경우 해당 행을 강조 표시하고 싶습니다. 그것은 어떤 이유로는 보이지 않습니다. if 문을 테스트 한 결과 작동합니다.결과에서 행 강조하기

<?php 
    // First of all initialise the user and check for permissions 
    require_once "/var/www/users/user.php"; 
    $user = new CHUser(7); 

    // Initialise the template 
    require_once "/var/www/template/template.php"; 
    $template = new CHTemplate(); 

    // And create a cid object 
    require_once "/var/www/WIPProgress/DisplayWIPOnLocation.php"; 
    $WIPProgress= new CHWIPProgress(); 
    $content = "<h1>Check WIP Status on Location </h1>"; 
    $content = 
     "<form action='index.php' method='get' name ='location'> 
      <select id='location' name ='location' > 
     <option>Skin Room</option> 
       <option>Clicking</option> 
       <option>Kettering</option> 
     <option>Closing</option> 
       <option>Rushden</option> 
       <option>Assembly</option> 
       <option>Lasting</option> 
       <option>Making</option> 
       <option>Finishing</option> 
       <option>Shoe Room</option> 
      </select> 
      <input type='submit' /> 
     </form>"; 

    if(isset($_GET['location'])) { 
     $wip = $WIPProgress->ListWIPOnLocation($_GET['location']); 
     $location = $_GET['location']; 
     $todays_date = date("Y-m-d H:i:s"); 

     // Now show the details 
     $content .= 
      "<h2>Details for $location </h2> 
      <table> 
       <tr> 
        <th>PPDescription</th> 
        <th>Works Order</th>     
        <th>Bundle Number</th> 
        <th>Bundle Reference</th> 
        <th>Due Date</th> 
       </tr>"; 

     foreach($wip as $x) { 
      if(strtotime($x['DueDate']) > strtotime($todays_date)){ 
       $content .= 
        "<tr bgcolor='#FF0000'> 
         <td>" . $x['Description'] . "</td> 
         <td>" . $x['WorksOrder'] . "</td> 
         <td>" . $x['Number'] . "</td> 
         <td>" . $x['Reference'] . "</td> 
         <td>" . $x['DueDate'] . "</td> 
        </tr>"; 
      } 
     } 
    } 
    else { 
     $content .= "<h3>Please choose a location to view WIP</h3>"; 
    } 

    $template->SetTag("content", $content); 
    echo $template->Display(); 
?> 

반환되는 행을 강조 표시하는 PHP 클래스가 있습니까?

+5

이 경우 CSS를 사용하십시오. –

+0

정상 흐름이 누락되어 강조 표시된 셀만 인쇄하고 있습니까? – Tokk

+0

아니요 그냥 강제로 싶었습니다 – user1010756

답변

0

bgcolortr으로 정의하는 대신 각 td을 정의하십시오.

또는 tr에 CSS 클래스를 연결하고 CSS를 통해 의 td을 모두 타겟팅하는 것이 더 좋습니다.

$content .= "<tr class='highlight'>..."; 

<style> 
.highlight td 
{ 
    background-color:#FF0000; 
} 
</style> 
+0

감사합니다.하지만 다른 방법으로는 효과가 없었으므로 조언을 받고 else 문을 추가했습니다. – user1010756

관련 문제