Reputation: 1070
i'm trying to get the sum of values in a column inside php but it's not working at all while the query works fine when testing in MySQL here's the code (updated with full code)
require('../_req/base.php');
$getCartQ = "select * from user_product inner join cart inner join products inner join users on user_product.User_ID = cart.User_ID and user_product.User_ID = users.User_ID group by cart.User_ID";
$getCartR = mysql_query($getCartQ);
?> <table align="center" width="1271" border="0" cellpadding="0" cellspacing="0">
<?php
while($cartRow = mysql_fetch_array($getCartR)){
$sumQ = "select SUM(Total) as total from user_product where Status = 'active' and user_product.User_ID = '$cartRow[User_ID]'";
$sumR = mysql_query($sumQ) or die(mysql_error());
$sumRow = mysql_fetch_assoc($sumR);
$cost = $sumRow['total'];
?>
<tr>
<td><?php echo $cartRow['Full_Name'] ?></td>
<td><?php echo $cartRow['State']; ?></td>
<td><?php echo $cost; ?></td>
</tr>
<?php
}
?>
</table>
<?php
mysql_close($connect);
when i try to echo $cost i get nothing just a blank space what's wrong with that code ?
Upvotes: 0
Views: 125
Reputation: 1070
I just deleted the cache and everything worked fine i don't know what this has to do with the cache thanks all for your help i appreciate it
Upvotes: 0
Reputation: 8372
user_product.User_ID = '$getCartR[User_ID]'";
to
user_product.User_ID = '{$getCartR['User_ID']}'";
Upvotes: 1
Reputation: 11832
do
echo mysql_error();
at the end and tell me what it's showing. You'll have your answer right there
Upvotes: 1