$billing_query="SELECT * FROM users_billing ORDER by name";
if($billing_result=mysql_query($billing_query)){
$rows=mysql_num_rows($billing_result);
$billing=mysql_fetch_array($billing_result);
echo "<style type=\"text/css\">
<!--
.header {font-family: \"Comic Sans MS\"; font-size: x-small; font-weight: bold;}
.danue {font-family: \"Comic Sans MS\"; color: #699DF8; font-size: x-small; font-weight: bold; }
.silki {font-family: \"Comic Sans MS\"; font-size: x-small; font-weight: bold; }
-->
</style>";
do{
if($prev_name==$billing['name'] || $prev_name==''){
echo $prev_name."=".$billing['name']."<br>";
$query="SELECT * FROM users_billing WHERE name='".$billing['name']."'";
do{
$billing_mbin=$billing_mbin+$billing['mbin'];
$billing_mbout=$billing_mbout+$billing['mbout'];
$billing_costs=$billing_costs+$billing['costs'];
$billing_paid=$billing_paid+$billing['paid'];
}while($query=mysql_query($query));
echo "<table border=\"1\" cellpadding=\"0\" cellspacing=\"0\" style=\"border-collapse: collapse\" bordercolor=\"#699DF8\" width=\"100%\" id=\"AutoNumber4\">
<tr>
<td colspan=\"7\" bgcolor=\"#FFCC00\"> <font face=\"Tahoma\" size=\"2\" color=\"#0E397A\"> <strong>Сумарная за все проживание в сети: </strong></font></td>
</tr>
<tr class=\"header\">
<td width=\"13%\" height=\"20\"><span class=\"style16\"> Имя:</span></td>
<td width=\"15%\"><span class=\"style16\"> Дата: </span></td>
<td width=\"12%\"><span class=\"style16\"> За сеть :</span></td>
<td width=\"14%\"><span class=\"style16\"> Mb заказал:</span></td>
<td width=\"19%\"><span class=\"style16\"> Mb использовал:</span></td>
<td width=\"13%\"><span class=\"style16\"> Стоимость:</span></td>
<td width=\"14%\"><span class=\"style16\"> Заплатил:</span></td>
</tr></tr>
<tr class=\"danue\">
<td> <font color=red>".$billing['name']."</font></td>
<td width=\"15%\"></td>
<td width=\"12%\"></td>
<td width=\"14%\"> <font color=red>".$billing_mbin." mb</font></td>
<td width=\"19%\"> <font color=red>".$billing_mbout." mb</font></td>
<td> <font color=red>".$billing_costs."$</font></td>
<td> <font color=red>".$billing_paid."$</font></td>
</tr></table><br><br>";
$prev_name==$billing['name'];
}else{
if($prev_name!='') echo "Закрываем<br>";
$query="SELECT * FROM users_billing WHERE name='".$billing['name']."'";
echo $prev_name."!=".$billing['name']."<br>";
$prev_name=$billing['name'];
}
}while($billing=mysql_fetch_array($billing_result));
}
получается беспрерывный цыкл!Автор оригинала: Stm
я тут посмотрел твой код, так ты вроде хочешь проссумировать поля у записей с одинаковым именем, если так то запрос нужно другой, типа:
SELECT name, SUM(mbin), SUM(mbout),SUM(costs),SUM(paid) FROM `users_billing` GROUP BY name
И что ты хотел этим сказать ?Автор оригинала: Фанат
.
if($billing_result=mysql_query('SELECT name, SUM(mbin), SUM(mbout),SUM(costs),SUM(paid) FROM `users_billing` GROUP BY name')){
echo "<style type=\"text/css\">
<!--
.header {font-family: \"Comic Sans MS\"; font-size: x-small; font-weight: bold;}
.danue {font-family: \"Comic Sans MS\"; color: #699DF8; font-size: x-small; font-weight: bold; }
.silki {font-family: \"Comic Sans MS\"; font-size: x-small; font-weight: bold; }
-->
</style>
<table border=\"1\" cellpadding=\"0\" cellspacing=\"0\" style=\"border-collapse: collapse\" bordercolor=\"#699DF8\" width=\"100%\" id=\"AutoNumber4\">
<tr>
<td colspan=\"7\" bgcolor=\"#FFCC00\"> <font face=\"Tahoma\" size=\"2\" color=\"#0E397A\"> <strong>Сумарная за все проживание в сети: </strong></font></td>
</tr>
<tr class=\"header\">
<td width=\"13%\" height=\"20\"><span class=\"style16\"> Имя:</span></td>
<td width=\"15%\"><span class=\"style16\"> Дата: </span></td>
<td width=\"12%\"><span class=\"style16\"> За сеть :</span></td>
<td width=\"14%\"><span class=\"style16\"> Mb заказал:</span></td>
<td width=\"19%\"><span class=\"style16\"> Mb использовал:</span></td>
<td width=\"13%\"><span class=\"style16\"> Стоимость:</span></td>
<td width=\"14%\"><span class=\"style16\"> Заплатил:</span></td>
</tr>";
while($billing=mysql_fetch_array($billing_result)){
echo "<tr class=\"danue\">
<td> <font color=red>".$billing['name']."</font></td>
<td width=\"15%\"></td>
<td width=\"12%\"></td>
<td width=\"14%\"> <font color=red>".$billing['SUM(mbin)']." mb</font></td>
<td width=\"19%\"> <font color=red>".$billing['SUM(mbout)']." mb</font></td>
<td> <font color=red>".$billing['SUM(costs)']."$</font></td>
<td> <font color=red>".$billing['SUM(paid)']."$</font></td>
</tr>";
}
echo "</table><br><br>";
}