Jump to content

Grand Total Not working


newbie_07

Recommended Posts

Hi

 

I am using the query for the grand total of the adjusted price.

Here's my query and it returns nothing:

 

$sql = "SELECT service_ordered, admin_comments, adj_price, sum(adj_price) as tot_price
  from services_ordered where services_ordered.client_id=$_POST[c_id] 
          group by service_ordered"; 

 

Any idea!

Link to comment
https://forums.phpfreaks.com/topic/106283-grand-total-not-working/
Share on other sites

Hello

 

It looks okey, but you should clean up your post value

 

$sql = 'SELECT service_ordered, admin_comments, adj_price, sum(adj_price) as tot_price
  from services_ordered where services_ordered.client_id='.(int)$_POST['c_id'].' 
          group by service_ordered'; 

ur query looks right first check your form field $_POST['c_id'] if you get value then try this query

 

$sql = "SELECT service_ordered, admin_comments, adj_price, sum(adj_price) as tot_price

  from services_ordered where services_ordered.client_id='".$_POST['c_id']."'

          group by service_ordered";

ur query looks right first check your form field $_POST['c_id'] if you get value then try this query

 

$sql = "SELECT service_ordered, admin_comments, adj_price, sum(adj_price) as tot_price

  from services_ordered where services_ordered.client_id='".$_POST['c_id']."'

          group by service_ordered";

 

Again not working :(. I don't know whats the problem.

When i test the query in mysql it works fine....

I have checked the $_post['c_id'] value is printing in the where clause.

please paste ur full query

 

Ok

 

$sql = "SELECT service_ordered, admin_comments, adj_price, sum(adj_price) as tot_price
     from services_ordered where services_ordered.client_id='".$_POST['c_id']."'
          group by service_ordered"; 		
	print "<br><br><br>".$sql ;
	$res = mysql_query($sql) or die(mysql_error());
		$f =	mysql_num_rows($res);
		echo "$f";

	while($row=mysql_fetch_array($res)){
		$s_names = $row['service_ordered'];
		$d_date = $row[''];
		$a_comments = $row['admin_comments'];
		$adj_price = $row['adj_price'];
	?>
        <td><?php echo "$s_names"; ?></td>
        <td> </td>
        <td><?php echo "$a_comments"; ?></td>
        <td align="center"><?php echo "$adj_price"; ?></td>
        </tr>
<?php } ?>
      <tr>
        <td colspan="3" class="trbg"><strong>Total Price: </strong></td>
        <td align="center"><?php echo "$tot_price"; ?></td>

Try this one

$sql = "SELECT service_ordered, admin_comments, adj_price
     from services_ordered where services_ordered.client_id='".$_POST['c_id']."'
          group by service_ordered"; 
print "<br><br><br>".$sql ;
res = mysql_query($sql) or die(mysql_error());
$f =
mysql_num_rows($res);
echo "$f";
while($row=mysql_fetch_array($res)){
$s_names = $row['service_ordered'];
$d_date = $row[''];
$a_comments = $row['admin_comments'];
$adj_price = $row['adj_price'];
$tot_price[]=$row['adj_price'];
?>
        <td><?php echo "$s_names"; ?></td>
        <td> </td>
        <td><?php echo "$a_comments"; ?></td>
        <td align="center"><?php echo "$adj_price"; ?></td>
        </tr>

<?php } ?>
      <tr>
        <td colspan="3" class="trbg"><strong>Total Price: </strong></td>
        <td align="center"><?php echo array_sum($tot_price); ?></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.