Jump to content

Recommended Posts

Can someone help?

 

I'm trying to calculate the total from the "Comm:" column.  (A.commission)

 

Can someone help??

 

Thanks.

 

----------------------

 

 

<script language="javascript" src="js/AnchorPosition.js"></script>
<script language="javascript" src="js/date.js"></script>
<script language="javascript" src="js/PopupWindow.js"></script>
<script language="javascript" src="js/CalendarPopup.js"></script>
<script language="javascript">
var cal = new CalendarPopup();

function onSubmitForm() {
    var frm = document.employeesearch;

		if(frm.epstartdate.value == "")
		{
			alert("Enter First date!");
			frm.epstartdate.focus();
			return false;
		}
		if(frm.ependdate.value == "")
		{
			alert("Enter Second date!");
			frm.ependdate.focus();
			return false;
		}
	}
</script><center><br />
<?php 	

	$epstartdate = $_POST["epstartdate"];
	$ependdate = $_POST["ependdate"];
	echo '<a target="_blank" href="printable.php?id='.$_SESSION["gUSER_ID"].'&sdate='.@$_POST['epstartdate'].'&edate='.@$_POST['ependdate'].'">Print</a>';



?></center><br />
<table border="1" width="90%" cellpadding="2" align="center">
  <tbody>
    <tr>
      <td colspan="8" height="30" valign="bottom"><table border="0" cellpadding="0" cellspacing="0" height="27" width="100%">
          <tbody>
            <tr>
              <td height="21" width="100%">
		    <div>View Tickets 
                </div>
                <form method="post" name="employeesearch" action="main.php?opt=view_my_tickets" onSubmit="return onSubmitForm()">
                  <p><font face="Tahoma" size="2">From:
                    <input name="epstartdate" id="epstartdate" onKeyPress="return txtBoxFormat(document.upload, 'epstartdate', '99/99/9999', event);" size="10" value="" type="text">
                    <a href="#" onClick="cal.select(document.forms['employeesearch'].epstartdate,'anchor1','yyyy-MM-dd'); return false;"name="anchor1" ID="anchor1"><img src="images/cal.gif" 			border="0" height="16" width="16"></a>   To:  <input name="ependdate" id="ependdate" onKeyPress="return txtBoxFormat(document.upload, 'ependdate', '99/99/9999', event);" size="10" value="" type="text">
                    <a href="#" onClick="cal.select(document.forms['employeesearch'].ependdate,'anchor2','yyyy-MM-dd'); return false;"
   						name="anchor2" ID="anchor2"><img src="images/cal.gif" border="0" height="16" width="16"></a>  
                    <input value="Filter Results" name="submit" type="submit">
                  </p>
                </form></td>
            </tr>
          </tbody>
      </table></td>
    </tr>
    <tr>
      <td colspan="8" height="30" valign="bottom"><font face="Tahoma" size="2"><b> My Tickets</b></font> </td>
    </tr>
<tr>
      <td style="" bgcolor="#e8f2ff" height="21" width="20%"><font face="Tahoma" size="2"><b> Ticket#:</b></font></td>
      <td style="" bgcolor="#e8f2ff" height="21" width="15%"><font face="Tahoma" size="2"><b> Date:</b></font></td>
      <td style="" bgcolor="#e8f2ff" height="21" width="19%"><font face="Tahoma" size="2"><b> Airline: </b></font></td>
      <td style="" bgcolor="#e8f2ff" height="21" width="18%"><font face="Tahoma" size="2"><b> Comm:</b></font></td>
      <td style="" bgcolor="#e8f2ff" height="21" width="17%"><font face="Tahoma" size="2"><b> Office:</b></font></td>
  <td style="" bgcolor="#e8f2ff" height="21" width="11%"><font face="Tahoma" size="2"><b> Notes:</b></font></td>
  <td style="" bgcolor="#e8f2ff" height="21" width="11%"><font face="Tahoma" size="2"><b> Edit:</b></font></td>
  <td style="" bgcolor="#e8f2ff" height="21" width="11%"><font face="Tahoma" size="2"><b> Delete:</b></font></td>
  </tr>
  <?php
	$rs = new Recordset($CFG->dbh);
	$rs->DEBUG=0;
	$v=0;
	$o=0;
	$w=0;
	$r=0;
	if(($epstartdate == "") || ($ependdate == ""))
		{
			if($_SESSION["gUSER_ID"]!=3) 
				{
			$sql = "SELECT 
			A.user_id, A.ticketnumber, A.date, A.airline,
			A.commission, A.notes, B.department, B.id 
			FROM ticket A, user B WHERE A.user_id = B.id AND A.user_id ='".$_SESSION["gUSER_ID"]."' ORDER BY A.airline";
				}							
			else
					{
			$sql = "SELECT 
			A.user_id, A.ticketnumber, A.date, A.airline,
			A.commission, A.notes, B.department, B.id 
			FROM ticket A, user B WHERE A.user_id = B.id ORDER BY A.airline";
					}	
	$rs->Execute($sql);

	while(!$rs->EOF())
	{

			echo '<tr>
				<td height="21" width="20%">'.$rs->fields["ticketnumber"].'</td>
				  <td height="21" width="20%">'.$rs->fields["date"].'</td>
				  <td height="21" width="20%">'.$rs->fields["airline"].'</td>
				  <td height="21" width="20%">'.$rs->fields["commission"].'</td>
				  <td height="21" width="20%">'.$rs->fields["department"].'</td>
				  <td height="21" width="20%">'.$rs->fields["notes"].'</td>
				   <td height="21" width="20%"><a href="main.php?opt=edit_tickets&ticketid='.$rs->fields["ticketnumber"].'&deptt='.$rs->fields["department"].'">Edit</a></td>
				  <td height="21" width="20%"><a href="main.php?opt=delete_tickets&ticketid='.$rs->fields["ticketnumber"].'&del=yes">Delete</a></td>
			  </tr>';
			  if($rs->fields["department"] == "vendas")
			  {$v++;}
			  if($rs->fields["department"] == "Owner")
			  {$o++;}
  			  if($rs->fields["department"] == "Reservation")
			  {$r++;}
		$rs->MoveNext();
	}
	}

	else
		{		
			if($_SESSION["gUSER_ID"]!=3) {
			$sql = "SELECT 
			A.user_id, A.ticketnumber, A.date, A.airline,
			A.commission, A.notes, B.department, B.id 
			FROM ticket A, user B WHERE A.user_id = B.id AND A.user_id ='".$_SESSION["gUSER_ID"]."' AND A.date between '$epstartdate' and '$ependdate' ORDER BY A.airline";
										}							
			else	
					{
			$sql = "SELECT 
			A.user_id, A.ticketnumber, A.date, A.airline,
			A.commission, A.notes, B.department, B.id 
			FROM ticket A, user B WHERE A.user_id = B.id AND A.date between '$epstartdate' and '$ependdate' ORDER BY A.airline";
					}	
				$rs->Execute($sql);
				while(!$rs->EOF())
			{	
				if($rs->fields["department"] == "vendas")
			    {$v =($v+1);}
			    if($rs->fields["department"] == "Owner")
			    {$o =($o+1);}
  			    if($rs->fields["department"] == "Reservation")
			    {$r =($r+1);}
				echo '<tr>
				<td height="21" width="20%">'.$rs->fields["ticketnumber"].'</td>
				<td height="21" width="20%">'.$rs->fields["date"].'</td>
				<td height="21" width="20%">'.$rs->fields["airline"].'</td>
				<td height="21" width="20%">'.$rs->fields["commission"].'</td>
				<td height="21" width="20%">'.$rs->fields["department"].'</td>
				<td height="21" width="20%">'.$rs->fields["notes"].'</td>
				<td height="21" width="20%"><a href="main.php?opt=edit_tickets&ticketid='.$rs->fields["ticketnumber"].'&deptt='.$rs->fields["department"].'">Edit</a></td>
				<td height="21" width="20%"><a href="main.php?opt=delete_tickets&ticketid='.$rs->fields["ticketnumber"].'&del=yes">Delete</a></td>
			  	</tr>';
				$rs->MoveNext();
			}

	 	 }
?>

  </tbody>
</table>

<table border="1" width="90%" cellpadding="2" align="center">
  <tbody>
<tr><td style="" bgcolor="#e8f2ff" height="21" width="20%"><font face="Tahoma" size="2"><b>Total Tickets:
<?php 	
	$res = mysql_query($sql);
	$num_rows = mysql_num_rows($res);
	echo $num_rows; 
								  
?>


</b></td></tr>
<tr><td style="" bgcolor="#e8f2ff" height="21" width="20%"><font face="Tahoma" size="2"><b>Total Offices: Vendas:
<?php echo $v;?> Owner:<?php echo $o;?> Reservation:<?php echo $r;?> Webmaster:<?php echo $w;?></b></font></td></tr>
<table border="1" width="90%" cellpadding="2" align="center">
<tbody>
<tr><td style="" bgcolor="#ffffff" height="21" width="20%"><font face="Tahoma" size="2">
<form><input type=button name="update" value="update" /></form></font></td></tr></tbody></table>

 

 

------------------------

Link to comment
https://forums.phpfreaks.com/topic/234152-calculate-column-total/
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.