Jump to content

undefined variale help


flemingmike

Recommended Posts

hello,  is anybody able to help me with why i am getting an undefined variable "total" on line 109?

 

<?php
include '../auth5.php';
include '../config.php';
include '../javascript.php';
include 'style.php';
echo "<br />";

  echo "<table border='1' style='border-collapse: collapse' bordercolorlight='#000000' bordercolordark='#000000' width='98%' align='center'>";
echo "<tr><td width='100%' colspan='7' align='center'><b>Unbilled Work</b></td></tr>";

echo "<tr>
		<th align='center'>Date</th>
		<th align='center'>Client</th>
		<th align='center'>Tech</th>
		<th align='center'>Service Report</th>
		<th align='center'>Hours Billed</th>
		<th align='center'>Total</th>
		<th align='center'>Parts Used</th>

</tr>";

$result = mysql_query("SELECT * FROM timesheets WHERE status = 3 AND billable = 1 ORDER BY date, starttime");
while($row = mysql_fetch_array($result))
{
$id=$row['id'];
$tech=$row['tech'];
$date=$row['date'];
$date1=date( 'M d', strtotime($date) );
$date2=date( 'D M j, Y', strtotime($date) );
$starttime=$row['starttime'];
$starttime1=date( 'g:i a', strtotime($starttime) );
$esttime=$row['esttime'];
$esttime1=date( 'g:i a', strtotime("$esttime hours, $starttime") );
$endtime=$row['endtime'];
$endtime1=date( 'g:i a', strtotime($endtime) );
$client=$row['client'];
$description=$row['description'];
$description=nl2br($description);
$status=$row['status'];
$report=$row['report'];
//$report=nl2br($report);
$billable=$row['billable'];
$remote=$row['remote'];
$parts=$row['parts'];


  if($endtime == "01:11:00") {
  $tbilled3 = "";
  $endtime1 = "";
  } elseif(empty($endtime)) {
  $tbilled3 = "";
  $endtime1 = "";
  } else {

$log_in_time_string = strtotime($starttime);
$log_out_time_string = strtotime($endtime);
$difference_in_seconds = ($log_out_time_string - $log_in_time_string);
$tbilled = ($difference_in_seconds / 3600);

  if($tbilled < 0)
{
    $tbilled1 = $tbilled + 24;
} else {
    $tbilled1=$tbilled;
}
  
  $tbilled2 = number_format(round($tbilled1*4)/4,2);
  
  
  if($remote == 1) {  
    if($tbilled2 < 1.5) {
    $tbilled3 = "2";
} else {
    $tbilled3 = $tbilled2 + 0.5;
}
} else {
$tbilled3 = $tbilled2;
}


}


$result5 = mysql_query("SELECT * FROM customers WHERE id = '$client'");
while($row5 = mysql_fetch_array($result5))
{
$clientname=$row5['name'];
$rate=$row5['rate'];
}	

$result6 = mysql_query("SELECT * FROM staff WHERE id = '$tech'");
while($row6 = mysql_fetch_array($result6))
{
$tech=$row6['name'];
}

$nlength = strlen($report);
$nremove = 30 - $nlength;
$report1 = substr($report, 0, $nremove);

$jobbill=$tbilled3*$rate;
$jobbill = number_format($jobbill, 2, '.', ',');

$replacement = array(",");
$pnone = array("");
$pplain = str_replace($replacement, $pnone, $jobbill);

  
$total += $pplain;
$total1 = number_format($total, 2, '.', ',');


echo "<tr>";
  echo "<td align='center'>" . $date2 . "</td>";
  echo "<td align='center'>" . $clientname . "</td>";
  echo "<td align='center'>" . $tech . "</td>";
  echo "<td>" . $report1 . "</td>";
  echo "<td align='center'>" . $tbilled3 . "</td>";
  echo "<td align='center'>$" . $jobbill . "</td>";
  


  echo "</tr>";

  }
  
    echo "<tr>";

  echo "<td colspan='5' align='right'><b>Total :</td>";
  echo "<td align='right'><b>$" . $total1 . "</td>";
  echo "<tdcolspan='2'></td>";

  echo "</tr>";
  
  
echo "</table>";







?>

Link to comment
https://forums.phpfreaks.com/topic/226730-undefined-variale-help/
Share on other sites

so in this case,

echo "<td align='center'>";
echo "<table border='0' style='border-collapse: collapse' bordercolorlight='#000000' bordercolordark='#000000' width='100%' align='center'>";
$result7 = mysql_query("SELECT * FROM parts WHERE timesheet = '$id'");
while($row7 = mysql_fetch_array($result7))
{

$partdescription=$row7['description'];
$partprice=$row7['price'];
$partprice = number_format($partprice, 2, '.', ',');

$replacementp = array(",");
$pnonep = array("");
$pplainp = str_replace($replacementp, $pnonep, $partprice);


$totalp += $pplainp;
$total1p = number_format($totalp, 2, '.', ',');

  echo "<tr>";	
  echo "<td>" . $partdescription . "</td>";
  echo "<td align='center' width='30'>$" . $partprice . "</td>";
  echo "</tr>";
}
echo "</table>";


echo "</td>";

 

id want it to look like

 

echo "<td align='center'>";
echo "<table border='0' style='border-collapse: collapse' bordercolorlight='#000000' bordercolordark='#000000' width='100%' align='center'>";
$result7 = mysql_query("SELECT * FROM parts WHERE timesheet = '$id'");
$totalp=0;
while($row7 = mysql_fetch_array($result7))
{

$partdescription=$row7['description'];
$partprice=$row7['price'];
$partprice = number_format($partprice, 2, '.', ',');

$replacementp = array(",");
$pnonep = array("");
$pplainp = str_replace($replacementp, $pnonep, $partprice);


$totalp += $pplainp;
$total1p = number_format($totalp, 2, '.', ',');

  echo "<tr>";	
  echo "<td>" . $partdescription . "</td>";
  echo "<td align='center' width='30'>$" . $partprice . "</td>";
  echo "</tr>";
}
echo "</table>";


echo "</td>";

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.