Angelojoseph17 Posted October 24, 2011 Share Posted October 24, 2011 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(); ?> Quote Link to comment https://forums.phpfreaks.com/topic/249700-highlighting-row/ Share on other sites More sharing options...
ManiacDan Posted October 24, 2011 Share Posted October 24, 2011 1) you are only printing the row if the date is higher than today's date. 2) <tr background-color: #CC9999;> That is invalid HTML. The style information should be inside a style attribute, or in a CSS class. Quote Link to comment https://forums.phpfreaks.com/topic/249700-highlighting-row/#findComment-1281761 Share on other sites More sharing options...
Angelojoseph17 Posted October 24, 2011 Author Share Posted October 24, 2011 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>"; } Quote Link to comment https://forums.phpfreaks.com/topic/249700-highlighting-row/#findComment-1281764 Share on other sites More sharing options...
ManiacDan Posted October 24, 2011 Share Posted October 24, 2011 That's exactly what I suggested, good work. Quote Link to comment https://forums.phpfreaks.com/topic/249700-highlighting-row/#findComment-1281772 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.