Jump to content

Flashy line help please


kat35601
Go to solution Solved by Barand,

Recommended Posts

Create_Date is a date and time field

 

I want to flash a row if the create_date is 20 hours old

<html>
<head>
<title>Status Screen</title>
</head>
<body>
<p> Open RedTags  </p>

<?php
$connect =odbc_connect("removed");
if(!$connect) {
	exit("Connection Failed: " . $connect);
}

$sql="SELECT uompschedulenumber, uompscheduleColor,jmaPartID,ompSalesOrderID, uomlSorP,serial,rail,panel,stile,upsdescription,itemtype
, uomlStyleGroup,status ,
Case
when status=10 then 'Created' 
 when status=3 then 'PreSanding' 
 when status=4 then 'PrePaint' else 
'' end as Status1
,getdate() as Created_Date
FROM WIP_master 
	where  redtag='Y' and redtagclosed !='Y'
	order by uompschedulenumber,uomlSorP,upsdescription,jmaPartID 	";

$result =odbc_exec($connect,$sql);
if(!$result){
exit("Error in SQL");
}
echo "<table cellspacing='10' border='1'><tr>";

echo "<th>PartID</th>";
echo "<th>OrderID</th>";
echo "<th>SorP</th>";
echo "<th>Serial</th>";
echo "<th>Rail</th>";
echo "<th>Panel</th>";
echo "<th>Description</th>";
echo "<th>ItemType</th>";
echo "<th>Stile</th>";
echo "<th>Created</th>";
echo "<th>Status</th>";
echo "<th>StatusDesc</th>";


while (odbc_fetch_row($result)) {
	$bgcolor= odbc_result($result, "uompscheduleColor");
	$jmaPartID= odbc_result($result, "jmaPartID");
	$ompSalesOrderID= odbc_result($result, "ompSalesOrderID");
	$uomlSorP= odbc_result($result, "uomlSorP");
	$serial= odbc_result($result, "serial");
	$rail= odbc_result($result, "rail");
	$panel= odbc_result($result, "panel");
	$stile= odbc_result($result, "stile");
	$upsdescription= odbc_result($result, "upsdescription");
	$itemtype = odbc_result($result, "itemtype");
   $uomlStyleGroup =  odbc_result($result, "uomlStyleGroup");
   $Created = odbc_result($result, "Created_Date");
   	$status = odbc_result($result, "status");
   		$status1 = odbc_result($result, "status1");
   

   

  echo "<tr><td bgcolor=$bgcolor >$jmaPartID</td>";
  echo "<td style='text-align:center'>$ompSalesOrderID</td>";
  echo "<td style='text-align:center'>$uomlSorP</td>";
  echo "<td style='text-align:center'>$serial</td>";
  echo "<td style='text-align:center'>	$panel</td>";
  echo "<td style='text-align:center'>	$stile</td>";
  echo "<td style='text-align:center'>	$upsdescription</td>";
  echo "<td style='text-align:center'>	$itemtype</td>";
  echo "<td style='text-align:center'>$uomlStyleGroup</td>";
   echo "<td style='text-align:center'>$Created</td>";
   echo "<td style='text-align:center'>$status</td>";
    echo "<td style='text-align:center'>$status1</td>";

  
 
}

odbc_close($connect);
?>
</body>
</html>

Link to comment
Share on other sites

How is your Created_Date stored before calling getdate() function?  

That function is returning YYYY-mm-dd HH:mm:ss.  

You could try strtotime() which will attempt to convert your string to a Unix timestamp.  

 

Once in Unix timestamp, you can apply some algorithm that will:

1. Calculate Created_Date plus 24 hours

2. compare current time() to Calculated (Created_Date + 24 hours) time. 

3. If current time() is greater than Calculated time, echo out some message

4. else do nothing

Link to comment
Share on other sites

I am sorry the first code has been updated to included the field Create_Date which is now a time stamp in our sql database.What I need is how to make a row flash what would be the code for that

 

my output is on an 80"screen and we want to flash rows that are older than 20 hours 

Link to comment
Share on other sites

Try this.  <blink> is unreliable and probably deprecated.  So <marquee> would be another option.

date_default_timezone_set("America/New_York");
	
$stored_date1 = "2015-08-01 01:30:00"; // in the past
$timestamp1 = strtotime($stored_date1);
	
$stored_date2 = "2015-08-12 03:00:00"; // in the future
$timestamp2 = strtotime($stored_date2);
	
function evalStoredTime($t) {
  $curtime = time();
  $calculated = $t + 86400; // + 24 hours
  if($calculated >= $curtime) {
	echo "The stored date/time plus 24 hours is in the future.";
  } else {
	echo '<marquee behavior="scroll" bgcolor="#00CCCC" loop="-1" width="40%">The stored date/time plus 24 hours is in the past.</marquee>';
  }
}
	
echo " Date/time 1: " . evalStoredTime($timestamp1);
echo "<br>";
echo " Date/time 2: " . evalStoredTime($timestamp2);
Edited by rwhite35
Link to comment
Share on other sites

  • Solution

This will do it using CSS

$sql = "SELECT timeslot
        , client
        , TIMESTAMPDIFF(HOUR, timeslot, NOW()) as elapsed
        FROM timeslots";
$res = $db->query($sql);
$rows = '';
while (list($ts, $cl, $el) = $res->fetch_row()) {
    $class = $el >= 20 ? 'class="blink"' : '';
    $rows .= "<tr><td>$cl</td><td $class>$ts</td></tr>\n";
}    
?>
<html>
<head>
<title>Example Flashing</title>
<style type='text/css'>
    /* The animation code */
    @keyframes flash {
        from {background-color: red;}
        to {background-color: white;}
    }

    /* The element to apply the animation to */
    td.blink {
        width: 100px;
        height: 100px;
        background-color: white;
        animation: flash 1s infinite;
    } 
</style>
</head>
<body>
    <table border="1">
    <tr><th>Client</th><th>Time</th></tr>
    <?=$rows?>
    </table>
</body>
</html>
  • Like 1
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.