[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

URGENT! error in code requires fixing!

Posted on 2004-11-19
11
Medium Priority
?
157 Views
Last Modified: 2006-11-17
Overview:

PHP page reads info form access db,

error somewhere within the php code at the date/time comparsing...

<?php

error_reporting(E_ALL); // Activate ALL errors/warnings/notices.

print_r($_POST); // Show the POST array in all its glory.

$rConn = odbc_connect("ConnLink","","");

// Check the results
$sResponse = '';

foreach(array('CommentsSubmitted', 'ResponsesSubmitted', 'CommentsApproved') as $sColumnName) {
      if (isset($_POST[$sColumnName])) {
            $sSQL = "UPDATE tblDataDocsReview SET $sColumnName = {$_POST[$sColumnName]} WHERE ID_no={$_POST['ID_no']};";
            // echo $sSQL; // Lets see what the query REALLY says.
            $rResult = odbc_exec($rConn, $sSQL) or die('Problem with the query.');
            // You may want to build a $sResponse to be put at the bottom of the page.
      }
}

// Get new results.
$rResult = odbc_exec ($rConn,"SELECT * FROM tblDataDocsReview");

$sOutput = <<< END_HTML
<html>
<head>
<meta http-equiv="refresh" content="50,defaults.php">
<style type="text/css">
      .global {font-family:Trebuchet MS;color:black;font-size:12px;text-decoration:none;}
      .tbl,td {font-family:Trebuchet MS;color:black;font-size:12px;text-decoration:none;border-bottom-style: solid;border-bottom-color: black;border-bottom-width: 1px;border-left-style: solid;border-left-color: black;border-left-width: 1px;border-top-style: solid;border-top-color: black;border-top-width: 1px;border-right-style: solid;border-right-color: black;border-right-width: 1px;cellpadding:0;cellspacing:0;}
      a{font-family:Trebuchet MS;font-size:12px;}
      a:visited{font-family:Trebuchet MS;font-size:12px;}
      a:hover{font-family:Trebuchet MS;font-size:12px;font-weight:bold;}
      a:active{font-family:Trebuchet MS;font-size:12px;}
</style>
<script language="JavaScript">
<!--
bAllowSubmit = true;

function SubmitForm(obj, uid) {
      if (bAllowSubmit == true) {
            bAllowSubmit = false; // Stop multiple clicks.
            document.HiddenForm.HiddenField.name = obj.name;
            if (obj.checked == true) {
                  document.HiddenForm.HiddenField.value = 1;
            } else {
                  document.HiddenForm.HiddenField.value = 0;
            }
            document.HiddenForm.UniqueID.value = uid;
            document.HiddenForm.submit();
      }
}


status = "BP - Project Endeavour - Tie-in Spool Execute Phrase";

var message = "Sorry! Right Click Disabled";

function clickIE4() {
      if (event.button == 2) {
            alert(message);
            return false;
      }
}

function clickNS4(e) {
      if (document.layers || document.getElementById && !document.all) {
            if (e.which == 2 || e.which == 3) {
                  alert(message);
                  return false;
            }
      }
}

if (document.layers) {
      document.captureEvents(Event.MOUSEDOWN);
      document.onmousedown = clickNS4;
} else if (document.all && !document.getElementById) {
      document.onmousedown = clickIE4;
}
document.oncontextmenu = new Function("alert(message);return false")


//-->
</script>
</head>
<body leftmargin="0" rightmargin="0" bottommargin="0" topmargin="24" bgcolor="white">
<form name="HiddenForm" method="POST" action="{$_SERVER['PHP_SELF']}">
     <input type="hidden" id="HiddenField" name="" value="">
     <input type="hidden" id="UniqueID" name="ID_no" value="">
</form>
<p class="global">Documents to be reviewed are as follows:</p>
<table width="97.5%" class="tbl">
<tr>
      <th width="10%" height="2%" valign="top" align="center">Entry Date</th>
      <th width="14%" height="2%" valign="top" align="center">Actionee</th>
      <th width="26%" height="2%" valign="top" align="center">Document to be Reviewed</th>
      <th width="20%" height="2%" valign="top" align="center">Comment Sheet</th>
      <th width="20%" height="2%" valign="top" align="center">Deadline Date/Time</th>
      <th width="8%" height="2%" valign="top" align="center">Comments Submitted</th>
      <th width="8%" height="2%" valign="top" align="center">Responses Submitted</th>
    <th width="8%" height="2%" valign="top" align="center">Comments Approved</th>
</tr>


END_HTML;

while (($aRow = odbc_fetch_array($rResult)) !== False) {

     $startdate = date('m/d/Y');
       $eventdate = $aRow['Months']."/".$aRow['Dates']."/".$aRow['Years'];

     foreach(array('CommentsSubmitted', 'ResponsesSubmitted', 'CommentsApproved') as $sColumnName) {
          $$sColumnName = ($aRow[$sColumnName] === '1')?' CHECKED':'';
     }
     $sOutput .= <<< END_HTML

<tr>
      <td width="10%" height="5%" valign="top" align="center">{$aRow['Date']}</td>
      <td width="14%" height="5%" valign="top" align="center">{$aRow['User']}</td>
      <td width="26%" height="5%" valign="top" align="center"><a href="{$aRow['FilePath']}" target="_blank">{$aRow['FilePathName']}</a></td>
      <td width="20%" height="5%" valign="top" align="center"><a href="{$aRow['CommentSheet']}" target="_blank">{$aRow['CommentName']}</a></td>
      <td width="20%" height="5%" valign="top" align="center">{$aRow['Dates']}/{$aRow['Months']}/{$aRow['Years']} @ {$aRow['Hours']}:{$aRow['Minutes']}:{$aRow['Seconds']}<br/>

<?php
if ((strtotime($eventdate)-strtotime($startdate))/(60.0*60.0*24.0)<= -1){
?>
      <span style="color:red;"><b>This Document is overdue</b></span>
<?php
}
elseif ((strtotime($eventdate)-strtotime($startdate))/(60.0*60.0*24.0)<= 1)
{
?>
      <span style="color:red;"><b><?php echo round((strtotime($eventdate)-(int)strtotime($startdate))/(60.0*60.0*24.0),0);?> days remaining</b></span>
<?php
}
else
{
      <span style="color:black;"><?php echo round((strtotime($eventdate)-(int)strtotime($startdate))/(60.0*60.0*24.0),0);?> days remaining</span>
<?php
}
?>
</td>
</tr>

END_HTML;
}

$sOutput .= <<< END_HTML
</table>
$sResponse
</body>
</html>
END_HTML;

echo $sOutput;
?>

no errors reporting but its shown "days remaining" and "document overdue" both at same time, plus checkbox arent shown either...


cheers

sean
0
Comment
Question by:ellandrd
  • 6
  • 3
  • 2
11 Comments
 
LVL 48

Expert Comment

by:hernst42
ID: 12626570
You can not use <?php -tags insed the HERE-DOCs. They are added to the HTMl-source and not executed.

$sOutput .= <<< END_HTML

END_HTML

So you should do it this way:
    $sOutput .= <<< END_HTML

<tr>
     <td width="10%" height="5%" valign="top" align="center">{$aRow['Date']}</td>
     <td width="14%" height="5%" valign="top" align="center">{$aRow['User']}</td>
     <td width="26%" height="5%" valign="top" align="center"><a href="{$aRow['FilePath']}" target="_blank">{$aRow['FilePathName']}</a></td>
     <td width="20%" height="5%" valign="top" align="center"><a href="{$aRow['CommentSheet']}" target="_blank">{$aRow['CommentName']}</a></td>
     <td width="20%" height="5%" valign="top" align="center">{$aRow['Dates']}/{$aRow['Months']}/{$aRow['Years']} @ {$aRow['Hours']}:{$aRow['Minutes']}:{$aRow['Seconds']}<br/>
END_HTML;

if ((strtotime($eventdate)-strtotime($startdate))/(60.0*60.0*24.0)<= -1){
$sOutput .= <<< END_HTML
     <span style="color:red;"><b>This Document is overdue</b></span>
END_HTML;

}
elseif ((strtotime($eventdate)-strtotime($startdate))/(60.0*60.0*24.0)<= 1)
{
$sOutput .= <<< END_HTML
     <span style="color:red;"><b><?php echo round((strtotime($eventdate)-(int)strtotime($startdate))/(60.0*60.0*24.0),0);?> days remaining</b></span>
END_HTML;

}
else
{
$sOutput .= <<< END_HTML
     <span style="color:black;"><?php echo round((strtotime($eventdate)-(int)strtotime($startdate))/(60.0*60.0*24.0),0);?> days remaining</span>
END_HTML;

}

 ..
0
 
LVL 16

Author Comment

by:ellandrd
ID: 12626915
can you possible add what youve done into this updated code:

<?php
error_reporting(E_ALL); // Activate ALL errors/warnings/notices.

print_r($_POST); // Show the POST array in all its glory.

$rConn = odbc_connect("ConnLink","","");

// Check the results
$sResponse = '';

foreach(array('CommentsSubmitted', 'ResponsesSubmitted', 'CommentsApproved') as $sColumnName) {
      if (isset($_POST[$sColumnName])) {
            $sSQL = "UPDATE tblDataDocsReview SET $sColumnName = {$_POST[$sColumnName]} WHERE ID_no={$_POST['ID_no']};";
            // echo $sSQL; // Lets see what the query REALLY says.
            $rResult = odbc_exec($rConn, $sSQL) or die('Problem with the query.');
            // You may want to build a $sResponse to be put at the bottom of the page.
      }
}

// Get new results.
$rResult = odbc_exec ($rConn,"SELECT * FROM tblDataDocsReview");

$sOutput = <<< END_HTML
<html>
<head>
<meta http-equiv="refresh" content="50,defaults.php">
<style type="text/css">
      .global {font-family:Trebuchet MS;color:black;font-size:12px;text-decoration:none;}
      .tbl,td {font-family:Trebuchet MS;color:black;font-size:12px;text-decoration:none;border-bottom-style: solid;border-bottom-color: black;border-bottom-width: 1px;border-left-style: solid;border-left-color: black;border-left-width: 1px;border-top-style: solid;border-top-color: black;border-top-width: 1px;border-right-style: solid;border-right-color: black;border-right-width: 1px;cellpadding:0;cellspacing:0;}
      a{font-family:Trebuchet MS;font-size:12px;}
      a:visited{font-family:Trebuchet MS;font-size:12px;}
      a:hover{font-family:Trebuchet MS;font-size:12px;font-weight:bold;}
      a:active{font-family:Trebuchet MS;font-size:12px;}
</style>
<script language="JavaScript">
<!--
bAllowSubmit = true;

function SubmitForm(obj, uid) {
      if (bAllowSubmit == true) {
            bAllowSubmit = false; // Stop multiple clicks.
            document.HiddenForm.HiddenField.name = obj.name;
            if (obj.checked == true) {
                  document.HiddenForm.HiddenField.value = 1;
            } else {
                  document.HiddenForm.HiddenField.value = 0;
            }
            document.HiddenForm.UniqueID.value = uid;
            document.HiddenForm.submit();
      }
}


status = "BP - Project Endeavour - Tie-in Spool Execute Phrase";

var message = "Sorry! Right Click Disabled";

function clickIE4() {
      if (event.button == 2) {
            alert(message);
            return false;
      }
}

function clickNS4(e) {
      if (document.layers || document.getElementById && !document.all) {
            if (e.which == 2 || e.which == 3) {
                  alert(message);
                  return false;
            }
      }
}

if (document.layers) {
      document.captureEvents(Event.MOUSEDOWN);
      document.onmousedown = clickNS4;
} else if (document.all && !document.getElementById) {
      document.onmousedown = clickIE4;
}
document.oncontextmenu = new Function("alert(message);return false")


//-->
</script>
</head>
<body leftmargin="0" rightmargin="0" bottommargin="0" topmargin="24" bgcolor="white">
<form name="HiddenForm" method="POST" action="{$_SERVER['PHP_SELF']}">
     <input type="hidden" id="HiddenField" name="" value="">
     <input type="hidden" id="UniqueID" name="ID_no" value="">
</form>
<p class="global">Documents to be reviewed are as follows:</p>
<table width="97.5%" class="tbl">
<tr>
      <th width="10%" height="2%" valign="top" align="center">Entry Date</th>
      <th width="14%" height="2%" valign="top" align="center">Actionee</th>
      <th width="26%" height="2%" valign="top" align="center">Document to be Reviewed</th>
      <th width="20%" height="2%" valign="top" align="center">Comment Sheet</th>
      <th width="20%" height="2%" valign="top" align="center">Deadline Date/Time</th>
      <th width="8%" height="2%" valign="top" align="center">Comments Submitted</th>
      <th width="8%" height="2%" valign="top" align="center">Responses Submitted</th>
    <th width="8%" height="2%" valign="top" align="center">Comments Approved</th>
</tr>


END_HTML;

while (($aRow = odbc_fetch_array($rResult)) !== False) {

     $startdate = date('m/d/Y');
       $eventdate = $aRow['Months']."/".$aRow['Dates']."/".$aRow['Years'];

     foreach(array('CommentsSubmitted', 'ResponsesSubmitted', 'CommentsApproved') as $sColumnName) {
          $$sColumnName = ($aRow[$sColumnName] === '1')?' CHECKED':'';
     }
$sOutput .= <<< END_HTML

<tr>
      <td width="10%" height="5%" valign="top" align="center">{$aRow['Date']}</td>
      <td width="14%" height="5%" valign="top" align="center">{$aRow['User']}</td>
      <td width="26%" height="5%" valign="top" align="center"><a href="{$aRow['FilePath']}" target="_blank">{$aRow['FilePathName']}</a></td>
      <td width="20%" height="5%" valign="top" align="center"><a href="{$aRow['CommentSheet']}" target="_blank">{$aRow['CommentName']}</a></td>
      <td width="20%" height="5%" valign="top" align="center">{$aRow['Dates']}/{$aRow['Months']}/{$aRow['Years']} @ {$aRow['Hours']}:{$aRow['Minutes']}:{$aRow['Seconds']}<br/>
      <td width="8%" height="5%" valign="top" align="center"><input type="checkbox" name="CommentsSubmitted" value=0 onClick="SubmitForm(this, {$aRow['ID_no']});"{$CommentsSubmitted}></td>
    <td width="8%" height="5%" valign="top" align="center"><input type="checkbox" name="ResponsesSubmitted" value=0 onClick="SubmitForm(this, {$aRow['ID_no']});"{$ResponsesSubmitted}></td>
    <td width="8%" height="5%" valign="top" align="center"><input type="checkbox" name="CommentsApproved" value=0 onClick="SubmitForm(this, {$aRow['ID_no']});"{$CommentsApproved}></td>

<?php
if ((strtotime($eventdate)-strtotime($startdate))/(60.0*60.0*24.0)<= -1){
?>
      <span style="color:red;"><b>This Document is overdue</b></span>
<?php
}
elseif ((strtotime($eventdate)-strtotime($startdate))/(60.0*60.0*24.0)<= 1)
{
?>
      <span style="color:red;"><b><?php echo round((strtotime($eventdate)-(int)strtotime($startdate))/(60.0*60.0*24.0),0);?> days remaining</b></span>
<?php
}
else
{
      <span style="color:black;"><?php echo round((strtotime($eventdate)-(int)strtotime($startdate))/(60.0*60.0*24.0),0);?> days remaining</span>
<?php
}
?>
</td>
</tr>

END_HTML;
}

$sOutput .= <<< END_HTML
</table>
$sResponse
</body>
</html>
END_HTML;

echo $sOutput;
?>

cheers

sean
0
 
LVL 48

Expert Comment

by:hernst42
ID: 12627026
Its very easy. replace the
<?php with $sOutput .= <<< END_HTML
and
\s*?> with END_HTML;

\s* means any whitespace like tab or spaces before the ?>.

where you have those tag inside such an here-doc/ if condition
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 16

Author Comment

by:ellandrd
ID: 12627055
ok forever add your answer to my code, ive updated it:

but ive got an extra $end somwhere so can you take a look??

<tr>
      <td width="10%" height="5%" valign="top" align="center">{$aRow['Date']}</td>
      <td width="14%" height="5%" valign="top" align="center">{$aRow['User']}</td>
      <td width="26%" height="5%" valign="top" align="center"><a href="{$aRow['FilePath']}" target="_blank">{$aRow['FilePathName']}</a></td>
      <td width="20%" height="5%" valign="top" align="center"><a href="{$aRow['CommentSheet']}" target="_blank">{$aRow['CommentName']}</a></td>
      <td width="20%" height="5%" valign="top" align="center">{$aRow['Dates']}/{$aRow['Months']}/{$aRow['Years']} @ {$aRow['Hours']}:{$aRow['Minutes']}:{$aRow['Seconds']}<br/>
      <td width="8%" height="5%" valign="top" align="center"><input type="checkbox" name="CommentsSubmitted" value=0 onClick="SubmitForm(this, {$aRow['ID_no']});"{$CommentsSubmitted}></td>
    <td width="8%" height="5%" valign="top" align="center"><input type="checkbox" name="ResponsesSubmitted" value=0 onClick="SubmitForm(this, {$aRow['ID_no']});"{$ResponsesSubmitted}></td>
    <td width="8%" height="5%" valign="top" align="center"><input type="checkbox" name="CommentsApproved" value=0 onClick="SubmitForm(this, {$aRow['ID_no']});"{$CommentsApproved}></td>

END_HTML;

if ((strtotime($eventdate)-strtotime($startdate))/(60.0*60.0*24.0)<= -1){

$sOutput .= <<< END_HTML

      <span style="color:red;"><b>This Document is overdue</b></span>


END_HTML;


}
elseif ((strtotime($eventdate)-strtotime($startdate))/(60.0*60.0*24.0)<= 1)
{

$sOutput .= <<< END_HTML

      <span style="color:red;"><b><?php echo round((strtotime($eventdate)-(int)strtotime($startdate))/(60.0*60.0*24.0),0);?> days remaining</b></span>

END_HTML;
}
else
{
$sOutput .= <<< END_HTML

      <span style="color:black;"><?php echo round((strtotime($eventdate)-(int)strtotime($startdate))/(60.0*60.0*24.0),0);?> days remaining</span>

END_HTML;


}

?>

</td>
</tr>

END_HTML;
}

$sOutput .= <<< END_HTML
</table>
$sResponse
</body>
</html>
END_HTML;

echo $sOutput;?>

somewhere in this part of code i think?

sean

0
 
LVL 16

Author Comment

by:ellandrd
ID: 12627092
still displaying "days remaining" and "document overdue" together!

somw how my if statements arent working...

any ideas

sean
0
 
LVL 16

Author Comment

by:ellandrd
ID: 12627103
heres my updated code:

<?php

error_reporting(E_ALL); // Activate ALL errors/warnings/notices.

print_r($_POST); // Show the POST array in all its glory.

$rConn = odbc_connect("ConnLink","","");

// Check the results
$sResponse = '';

foreach(array('CommentsSubmitted', 'ResponsesSubmitted', 'CommentsApproved') as $sColumnName) {
      if (isset($_POST[$sColumnName])) {
            $sSQL = "UPDATE tblDataDocsReview SET $sColumnName = {$_POST[$sColumnName]} WHERE ID_no={$_POST['ID_no']};";
            // echo $sSQL; // Lets see what the query REALLY says.
            $rResult = odbc_exec($rConn, $sSQL) or die('Problem with the query.');
            // You may want to build a $sResponse to be put at the bottom of the page.
      }
}

// Get new results.
$rResult = odbc_exec ($rConn,"SELECT * FROM tblDataDocsReview");

$sOutput = <<< END_HTML
<html>
<head>
<meta http-equiv="refresh" content="50,defaults.php">
<style type="text/css">
      .global {font-family:Trebuchet MS;color:black;font-size:12px;text-decoration:none;}
      .tbl,td {font-family:Trebuchet MS;color:black;font-size:12px;text-decoration:none;border-bottom-style: solid;border-bottom-color: black;border-bottom-width: 1px;border-left-style: solid;border-left-color: black;border-left-width: 1px;border-top-style: solid;border-top-color: black;border-top-width: 1px;border-right-style: solid;border-right-color: black;border-right-width: 1px;cellpadding:0;cellspacing:0;}
      a{font-family:Trebuchet MS;font-size:12px;}
      a:visited{font-family:Trebuchet MS;font-size:12px;}
      a:hover{font-family:Trebuchet MS;font-size:12px;font-weight:bold;}
      a:active{font-family:Trebuchet MS;font-size:12px;}
</style>
<script language="JavaScript">
<!--
bAllowSubmit = true;

function SubmitForm(obj, uid) {
      if (bAllowSubmit == true) {
            bAllowSubmit = false; // Stop multiple clicks.
            document.HiddenForm.HiddenField.name = obj.name;
            if (obj.checked == true) {
                  document.HiddenForm.HiddenField.value = 1;
            } else {
                  document.HiddenForm.HiddenField.value = 0;
            }
            document.HiddenForm.UniqueID.value = uid;
            document.HiddenForm.submit();
      }
}


status = "BP - Project Endeavour - Tie-in Spool Execute Phrase";

var message = "Sorry! Right Click Disabled";

function clickIE4() {
      if (event.button == 2) {
            alert(message);
            return false;
      }
}

function clickNS4(e) {
      if (document.layers || document.getElementById && !document.all) {
            if (e.which == 2 || e.which == 3) {
                  alert(message);
                  return false;
            }
      }
}

if (document.layers) {
      document.captureEvents(Event.MOUSEDOWN);
      document.onmousedown = clickNS4;
} else if (document.all && !document.getElementById) {
      document.onmousedown = clickIE4;
}
document.oncontextmenu = new Function("alert(message);return false")


//-->
</script>
</head>
<body leftmargin="0" rightmargin="0" bottommargin="0" topmargin="24" bgcolor="white">
<form name="HiddenForm" method="POST" action="{$_SERVER['PHP_SELF']}">
     <input type="hidden" id="HiddenField" name="" value="">
     <input type="hidden" id="UniqueID" name="ID_no" value="">
</form>
<p class="global">Documents to be reviewed are as follows:</p>
<table width="97.5%" class="tbl">
<tr>
      <th width="10%" height="2%" valign="top" align="center">Entry Date</th>
      <th width="14%" height="2%" valign="top" align="center">Actionee</th>
      <th width="26%" height="2%" valign="top" align="center">Document to be Reviewed</th>
      <th width="20%" height="2%" valign="top" align="center">Comment Sheet</th>
      <th width="20%" height="2%" valign="top" align="center">Deadline Date/Time</th>
      <th width="8%" height="2%" valign="top" align="center">Comments Submitted</th>
      <th width="8%" height="2%" valign="top" align="center">Responses Submitted</th>
    <th width="8%" height="2%" valign="top" align="center">Comments Approved</th>
</tr>


END_HTML;

while (($aRow = odbc_fetch_array($rResult)) !== False) {

     $startdate = date('m/d/Y');
       $eventdate = $aRow['Months']."/".$aRow['Dates']."/".$aRow['Years'];

     foreach(array('CommentsSubmitted', 'ResponsesSubmitted', 'CommentsApproved') as $sColumnName) {
          $$sColumnName = ($aRow[$sColumnName] === '1')?' CHECKED':'';
     }


$sOutput .= <<< END_HTML

<tr>
      <td width="10%" height="5%" valign="top" align="center">{$aRow['Date']}</td>
      <td width="14%" height="5%" valign="top" align="center">{$aRow['User']}</td>
      <td width="26%" height="5%" valign="top" align="center"><a href="{$aRow['FilePath']}" target="_blank">{$aRow['FilePathName']}</a></td>
      <td width="20%" height="5%" valign="top" align="center"><a href="{$aRow['CommentSheet']}" target="_blank">{$aRow['CommentName']}</a></td>
      <td width="20%" height="5%" valign="top" align="center">{$aRow['Dates']}/{$aRow['Months']}/{$aRow['Years']} @ {$aRow['Hours']}:{$aRow['Minutes']}:{$aRow['Seconds']}<br/>
      <td width="8%" height="5%" valign="top" align="center"><input type="checkbox" name="CommentsSubmitted" value=0 onClick="SubmitForm(this, {$aRow['ID_no']});"{$CommentsSubmitted}></td>
    <td width="8%" height="5%" valign="top" align="center"><input type="checkbox" name="ResponsesSubmitted" value=0 onClick="SubmitForm(this, {$aRow['ID_no']});"{$ResponsesSubmitted}></td>
    <td width="8%" height="5%" valign="top" align="center"><input type="checkbox" name="CommentsApproved" value=0 onClick="SubmitForm(this, {$aRow['ID_no']});"{$CommentsApproved}></td>

END_HTML;

if ((strtotime($eventdate)-strtotime($startdate))/(60.0*60.0*24.0)<= -1){

$sOutput .= <<< END_HTML

      <span style="color:red;"><b>This Document is overdue</b></span>


END_HTML;


}
elseif ((strtotime($eventdate)-strtotime($startdate))/(60.0*60.0*24.0)<= 1)
{

$sOutput .= <<< END_HTML

      <span style="color:red;"><b><?php echo round((strtotime($eventdate)-(int)strtotime($startdate))/(60.0*60.0*24.0),0);?> days remaining</b></span>

END_HTML;
}
else
{
$sOutput .= <<< END_HTML

      <span style="color:black;"><?php echo round((strtotime($eventdate)-(int)strtotime($startdate))/(60.0*60.0*24.0),0);?> days remaining</span>

END_HTML;


}
$sOutput .= <<< END_HTML

</td>
</tr>

END_HTML;
}

$sOutput .= <<< END_HTML
</table>
$sResponse
</body>
</html>
END_HTML;

echo $sOutput;?>

sean
0
 
LVL 48

Accepted Solution

by:
hernst42 earned 2000 total points
ID: 12627109

$sOutput .= <<< END_HTML

     <span style="color:red;"><b><?php echo round((strtotime($eventdate)-(int)strtotime($startdate))/(60.0*60.0*24.0),0);?> days remaining</b></span>

END_HTML;

Should better be written as the following as it also contains php-tags:

$sOutput .= <<< END_HTML
     <span style="color:red;"><b>
END_HTML;
$sOutput .= round((strtotime($eventdate)-(int)strtotime($startdate))/(60.0*60.0*24.0),0);
$sOutput .= <<< END_HTML
days remaining</b></span>

END_HTML;
}
else
{
$sOutput .= <<< END_HTML

     <span style="color:black;">
END_HTML;
 $sOutput .= round((strtotime($eventdate)-(int)strtotime($startdate))/(60.0*60.0*24.0),0);?>
$sOutput .= <<< END_HTML
days remaining</span>

END_HTML;

0
 
LVL 16

Author Comment

by:ellandrd
ID: 12627379
still not working! it displays doc overdue and days remaining everywhere now...

sean
0
 
LVL 27

Expert Comment

by:Diablo84
ID: 12627566
Theres a lot of html assigned to php that doesn't need to be parsed so i would scrap heredoc and do something like this:

<?php
error_reporting(E_ALL); // Activate ALL errors/warnings/notices.
print_r($_POST); // Show the POST array in all its glory.
?>

<html>
<head>
<meta http-equiv="refresh" content="50,defaults.php">
<style type="text/css">
     .global {font-family:Trebuchet MS;color:black;font-size:12px;text-decoration:none;}
     .tbl,td {font-family:Trebuchet MS;color:black;font-size:12px;text-decoration:none;border-bottom-style: solid;border-bottom-color: black;border-bottom-width: 1px;border-left-style: solid;border-left-color: black;border-left-width: 1px;border-top-style: solid;border-top-color: black;border-top-width: 1px;border-right-style: solid;border-right-color: black;border-right-width: 1px;cellpadding:0;cellspacing:0;}
     a{font-family:Trebuchet MS;font-size:12px;}
     a:visited{font-family:Trebuchet MS;font-size:12px;}
     a:hover{font-family:Trebuchet MS;font-size:12px;font-weight:bold;}
     a:active{font-family:Trebuchet MS;font-size:12px;}
</style>
<script language="JavaScript">
<!--
bAllowSubmit = true;

function SubmitForm(obj, uid) {
     if (bAllowSubmit == true) {
          bAllowSubmit = false; // Stop multiple clicks.
          document.HiddenForm.HiddenField.name = obj.name;
          if (obj.checked == true) {
               document.HiddenForm.HiddenField.value = 1;
          } else {
               document.HiddenForm.HiddenField.value = 0;
          }
          document.HiddenForm.UniqueID.value = uid;
          document.HiddenForm.submit();
     }
}


status = "BP - Project Endeavour - Tie-in Spool Execute Phrase";

var message = "Sorry! Right Click Disabled";

function clickIE4() {
     if (event.button == 2) {
          alert(message);
          return false;
     }
}

function clickNS4(e) {
     if (document.layers || document.getElementById && !document.all) {
          if (e.which == 2 || e.which == 3) {
               alert(message);
               return false;
          }
     }
}

if (document.layers) {
     document.captureEvents(Event.MOUSEDOWN);
     document.onmousedown = clickNS4;
} else if (document.all && !document.getElementById) {
     document.onmousedown = clickIE4;
}
document.oncontextmenu = new Function("alert(message);return false")


//-->
</script>
</head>
<body leftmargin="0" rightmargin="0" bottommargin="0" topmargin="24" bgcolor="white">
<form name="HiddenForm" method="POST" action="<?php echo $_SERVER['PHP_SELF']; ?>">
     <input type="hidden" id="HiddenField" name="" value="">
     <input type="hidden" id="UniqueID" name="ID_no" value="">
</form>
<p class="global">Documents to be reviewed are as follows:</p>
<table width="97.5%" class="tbl">
<tr>
     <th width="10%" height="2%" valign="top" align="center">Entry Date</th>
     <th width="14%" height="2%" valign="top" align="center">Actionee</th>
     <th width="26%" height="2%" valign="top" align="center">Document to be Reviewed</th>
     <th width="20%" height="2%" valign="top" align="center">Comment Sheet</th>
     <th width="20%" height="2%" valign="top" align="center">Deadline Date/Time</th>
     <th width="8%" height="2%" valign="top" align="center">Comments Submitted</th>
     <th width="8%" height="2%" valign="top" align="center">Responses Submitted</th>
    <th width="8%" height="2%" valign="top" align="center">Comments Approved</th>
</tr>

<?php
$rConn = odbc_connect("ConnLink","","");

// Check the results
$sResponse = '';

foreach(array('CommentsSubmitted', 'ResponsesSubmitted', 'CommentsApproved') as $sColumnName) {
 if (isset($_POST[$sColumnName])) {
  $sSQL = "UPDATE tblDataDocsReview SET $sColumnName = '{$_POST[$sColumnName]}' WHERE ID_no = '{$_POST['ID_no']}';";
  $rResult = odbc_exec($rConn, $sSQL) or die('Problem with the query.');
 }
}

// Get new results.
$rResult = odbc_exec ($rConn,"SELECT * FROM tblDataDocsReview");
$sOutput = "";

while (($aRow = odbc_fetch_array($rResult)) !== false) {
 $startdate = date('m/d/Y');
 $eventdate = $aRow['Months']."/".$aRow['Dates']."/".$aRow['Years'];

 foreach(array('CommentsSubmitted', 'ResponsesSubmitted', 'CommentsApproved') as $sColumnName) {
  $$sColumnName = ($aRow[$sColumnName] == '1') ? ' CHECKED' : '';
 }


 $sOutput .= '
 <tr>
     <td width="10%" height="5%" valign="top" align="center">'.$aRow['Date'].'</td>
     <td width="14%" height="5%" valign="top" align="center">'.$aRow['User'].'</td>
     <td width="26%" height="5%" valign="top" align="center"><a href="'.$aRow['FilePath'].'" target="_blank">'.$aRow['FilePathName'].'</a></td>
     <td width="20%" height="5%" valign="top" align="center"><a href="'.$aRow['CommentSheet'].'" target="_blank">'.$aRow['CommentName'].'</a></td>
     <td width="20%" height="5%" valign="top" align="center">'.$aRow['Dates'].'/'.$aRow['Months'].'/'.$aRow['Years'].' @ '.$aRow['Hours'].':'.$aRow['Minutes'].':'.$aRow['Seconds'].'<br/>
     <td width="8%" height="5%" valign="top" align="center"><input type="checkbox" name="CommentsSubmitted" value=0 onClick="SubmitForm(this, '.$aRow['ID_no'].');"'.$CommentsSubmitted.'></td>
    <td width="8%" height="5%" valign="top" align="center"><input type="checkbox" name="ResponsesSubmitted" value=0 onClick="SubmitForm(this, '.$aRow['ID_no'].');"'.$ResponsesSubmitted.'></td>
    <td width="8%" height="5%" valign="top" align="center"><input type="checkbox" name="CommentsApproved" value=0 onClick="SubmitForm(this, '.$aRow['ID_no'].');"'.$CommentsApproved.'></td>';

 if ((strtotime($eventdate)-strtotime($startdate))/(60.0*60.0*24.0)<= -1) {
  $sOutput .= '<span style="color:red;"><b>This Document is overdue</b></span>';
 }
 elseif ((strtotime($eventdate)-strtotime($startdate))/(60.0*60.0*24.0)<= 1) {
  $sOutput .= '<span style="color:red;"><b>'.round((strtotime($eventdate)-(int)strtotime($startdate))/(60.0*60.0*24.0),0).' days remaining</b></span>';
 }
 else {
  $sOutput .= '<span style="color:black;">'.round((strtotime($eventdate)-(int)strtotime($startdate))/(60.0*60.0*24.0),0).' days remaining</span>';
 }

}

echo $sOutput;
?>


</td>
</tr>
</table>

<?php echo $sResponse; ?>

</body>
</html>
0
 
LVL 16

Author Comment

by:ellandrd
ID: 12642272
sorry got my code working with hernst42.  using heredoc wasnt the problem to why my "days remaining" wasnt seeting in the correct place was i had <td> tag in wrong place....

thanks guys for all the help!

sean
0
 
LVL 27

Expert Comment

by:Diablo84
ID: 12643848
Your code would still be more efficient with the above.

.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn how to dynamically set the form action using jQuery.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Suggested Courses
Course of the Month20 days, 8 hours left to enroll

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question