Query as student id and show it as total pay. I was post before about this problem. maybe I was not able to clear my question.so I post it again. please help me
http://i.stack.imgur.com/SuYwb.jpg
<?php
$host="localhost"; // Host name
$username="root"; // Mysql username
$password=""; // Mysql password
$db_name="test"; // Database name
// Connect to server and select database.
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
?>
<?php
$sql0="SELECT * FROM payment as std_id GROUP BY std_id ";
$sql="SELECT SUM(pay) FROM payment as std_id GROUP BY std_id ";
$result0=mysql_query($sql0);
$result=mysql_query($sql);
?>
<table width="400" border="0" cellspacing="1" cellpadding="0">
<tr>
<td>
<table width="400" border="1" cellspacing="0" cellpadding="3">
<tr>
<td colspan="6"><div align="center"><strong>List data from mysql </strong> </div></td>
</tr>
<tr>
<td align="center"><strong>std id</strong></td>
<td align="center"><strong>pay</strong></td>
<?php
while($rows0=mysql_fetch_array($result0)) {
?>
<tr>
<?php
while($rows=mysql_fetch_array($result)) {
?>
<td><?php echo $rows0['std_id']; ?></td>
<td><?php echo $rows['SUM(pay)']; ?></td>
</tr>
<?php
}
}
?>
</table>
</td>
</tr>
</table>
<?php
mysql_close();
?>
See Question&Answers more detail:os