Jump to content

Highlighting row


Angelojoseph17

Recommended Posts

I have a php script which returns rows from a table. I match one of the dates in the table againsts todays date. If older than today the aim is to highlight the row. But some reason this is not working. I have tested my if statement with an echo which returns the right field. Can anyone spot the mistake?

 

 



<?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 background-color: #CC9999;>

					<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();





?>

Link to comment
https://forums.phpfreaks.com/topic/249700-highlighting-row/
Share on other sites

I fixed it, dont worry. I add an entry on the css sheet and i also changed my if statement.

 

 

 

if(strtotime($x['DueDate']) < strtotime($todays_date)){ 

             

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

					<td>" . $x['Description'] . "</td>

					<td>" . $x['WorksOrder'] . "</td>

					<td>" . $x['Number'] . "</td>

					<td>" . $x['Reference'] . "</td>

                                                <td>" . $x['DueDate'] . "</td>

                                                <td>" . $x['Stock'] . "</td>

				</tr>";

	}

            else 

                  { 



                 $content .= "<tr>

					<td>" . $x['Description'] . "</td>

					<td>" . $x['WorksOrder'] . "</td>

					<td>" . $x['Number'] . "</td>

					<td>" . $x['Reference'] . "</td>

                                                <td>" . $x['DueDate'] . "</td>

                                                <td>" . $x['Stock'] . "</td>

				</tr>";

	}

Link to comment
https://forums.phpfreaks.com/topic/249700-highlighting-row/#findComment-1281764
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.