Sorry. The problem is it is not giving me the total from the cost column. When I try it by itself it works fine except I won't get the other information just the total cost. I am trying to get the information and the total cost. I made the change you recommended, here is the rest of it:
$chk_id = "SELECT vid FROM maint WHERE vid = \"$vid\"";
$chk_id_res = @($chk_id,$connection) or die("Couldn't execute query.");
$chk_id_num = mysql_num_rows($chk_id_res);
if ($chk_id_num == "0") {
echo "$logo";
echo "<body bgcolor=\"$bg_color\" background=\"$background\" text=\"$tcolor\" link=\"#ffffff\" alink=\"#ffffff\" vlink=\"#ffffff\"";
echo "<p> <i><font size=\"3\" face=\"arial\" color=\"#FFFFFF\">Sorry, No Records Found!</font></i></p>";
echo " <a href=\"show_addmaint.php?vid=$vid\"><img src=\"images/sm_plus.gif\" border=\"0\" alt=\"Add A Maintenance Record\"><font size=2 face=arial>Add A Maintenance Record</font></a>";
echo "<br> $author";
exit;
} else {
echo "$logo";
echo "<body bgcolor=\"$bg_color\" background=\"$background\" text=\"$tcolor\" link=\"#FFFFFF\" vlink=\"#FFFFFF\" alink=\"#FFFFFF\"";
$sql = "
SELECT *
FROM maint, lsv
WHERE maint.vid = '$vid'
AND maint.vid = 'lsv.vid'
ORDER BY maint.date DESC
";
$sql .= "SELECT SUM(maint.cost) as totalcost FROM maint, lsv WHERE maint.vid = '$vid' AND maint.vid = lsv.vid";
$result = @($sql,$connection) or die("Couldn't execute query.");
$the_maint = "
<table width=100% cellpadding=2 cellspacing=2 border=0>
<tr>
<td bgcolor=#800000><font size=1 face=arial color=#ffffff>Date:</font></td>
<td bgcolor=#800000><font size=1 face=arial color=#ffffff>Maintenance Performed:</font></td>
<td bgcolor=#800000><font size=1 face=arial color=#ffffff>Type:</font></td>
<td bgcolor=#800000><font size=1 face=arial color=#ffffff>Cost:</font></td>
<td bgcolor=#800000><font size=1 face=arial color=#ffffff>Technician:</font></td>
<td bgcolor=#800000><font size=1 face=arial color=#ffffff>Edit:</font></td>
</tr>
";
while ($row = mysql_fetch_array($result)) {
$id = $row['id'];
$vid = $row['vid'];
$date = $row['date'];
$date=date('d M Y',strtotime($date));
$mdisc = $row['mdisc'];
$mtype = $row['mtype'];
$cost = $row['cost'];
$tech = $row['tech'];
$reg = $row['reg'];
$sn = $row['sn'];
$org = $row['org'];
$vco_n = $row['vco_n'];
$vco_e = $row['vco_e'];
$totalcost = $row['totalcost'];
$the_maint .= "<tr>
<td bgcolor=#808080><font size=1 face=arial>$date</font></td>
<td bgcolor=#808080><font size=1 face=arial>$mdisc</font></td>
<td bgcolor=#808080><font size=1 face=arial>$mtype</font></td>
<td bgcolor=#808080><font size=1 face=arial>$cost</font></td>
<td bgcolor=#808080><font size=1 face=arial>$tech</font></td>
<td bgcolor=#808080 width=\"3%\"><center><a href=\"update_maintrecord.php?id=$id\"><img src=\"images/edit_pencil.gif\" border=\"0\" alt=\"Edit\"></a></center></td>
";
}
$the_maint .= "</tr></table>";
echo "
<table width=300 cellpadding=3 cellspacing=3 border=0><tr><td>
<a href=\"view_singleunit.php?org=$org\"><img src=\"images/sm_goback.gif\" border=0 alt=\"Go Back To $org Thread\"></a>
<font size=2 face=arial width=300> Go Back To $org Thread </font>
</td></tr></table>
<br><br>
<table width=450 cellpadding=2 cellspacing=2 border=0>
<tr>
<td><font size=2 face=arial width=150><b>Cart Plate Number:</b></font></td>
<td><font size=2 face=arial width=300>$reg</font></td>
</tr>
<tr>
<td><font size=2 face=arial width=150><b>Cart Serial Number:</b></font></td>
<td><font size=2 face=arial width=300>$sn</font></td>
</tr>
<tr>
<td><font size=2 face=arial width=150><b>Organization:</b></font></td>
<td><font size=2 face=arial width=300><a href=\"view_singleunit.php?org=$org\">$org</a></font></td>
</tr>
<tr>
<td><font size=2 face=arial width=150><b>VCO:</b></font></td>
<td><font size=2 face=arial width=300>$vco_n</font></td>
</tr>
<tr>
<td><font size=2 face=arial width=150><b>Phone:</b></font></td>
<td><font size=2 face=arial width=300>$vco_e</font></td>
</tr>
<tr>
<td><font size=2 face=arial width=150><b></b></font></td>
<td><font size=2 face=arial width=300><a href=\"show_addmaint.php?vid=$vid\"><img src=\"images/add_maint.gif\" border=\"0\" alt=\"Add Maintenance Record\"></a> Add Maintenance Record</font></td>
</tr>
</table>
";
echo "<br> $the_maint";
echo "<br><font size=\"2\" face=\"arial\">Total Spent On Maintenance: $$totalcost</font>";
echo "<br> $author";
exit;
}
?>