2011-10-24 48 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

或更好的方式將CSS類與tr相關聯,並通過CSS定位此tr的所有td

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

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

謝謝你的工作但我採取了建議,並添加了其他聲明,因爲它不會工作,否則。 – user1010756

相關問題