2011-10-24 1 views
1

私はPHPの結果から5列を返すスクリプトを持っています。私は現在の日付に対して期日の列の1つを一致させようとしています。返される日付が古い場合、その行を強調表示したいと思います。何らかの理由でそうではないようです。私は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を使用してこのtrtdをすべてターゲットに設定することをお勧めします。

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

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

うまくいってくれてありがとうございます。しかし、別の方法ではうまくいきませんでしたので、私はアドバイスをしてelse文を追加しました。 – user1010756

関連する問題