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
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'; 

Link to comment
Share on other sites

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";

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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>

Link to comment
Share on other sites

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>

Link to comment
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.