PHP에서 열의 값의 합계를 얻으려고하고 있지만 그것은 MySQL에서 테스트 할 때 쿼리가 잘 작동하는 동안 전혀 작동하지 않습니다. 코드는 다음과 같습니다. 코드)PHP에서 열의 합계가 작동하지 않습니다
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);
내가 그 코드 뭐가 잘못 난 아무것도 단지 빈 공간 얻을 $ 비용을 에코하려고?
PHP에는 mysql api를 사용하지 말아야한다. MySQLi 또는 PDO를 사용하십시오. PHP 5.5.0 이후로 더 이상 사용되지 않습니다 –
쿼리 $ sumQ 바로 전에 연결 개체를 반향시키고 그것이 존재하는지 여부를 확인하십시오. –
코드 블록 안에 "mysql_query"가있는 질문에 대한 자동 주석으로 "SQLite/PDO를 사용하지 마십시오"라는 autoposts가 내장 된 마법 함수가 있어야합니다. 사람들이 매일 쓰는 낭비되는 노동 시간을 생각해보십시오. – Uberfuzzy