june_c21 Posted November 3, 2007 Share Posted November 3, 2007 hi, i want to output the report that content (start_date,end_date,user.name, report.staff_no,details,amount,gl_code,acc_no) into a table and then calculate total amount of user claim and output it in the last column. i try this but got error with my code and i don't know how to solve it. please help,thanks $query = "SELECT start_date,end_date,user.name, report.staff_no,details,amount,gl_code,acc_no FROM user,report WHERE report.staff_no = user.staff_no"; $result = mysql_query($query, $dblink); echo "<table border=3 align=center width=70%>"; echo "<tr><td width=12% align=center><span class=style5>Start Date </td></span>"; echo "<td width=12% align=center><span class=style5>End Date</td></span>"; echo "<td align=center><span class=style5>Name</td></span>"; echo "<td align=center><span class=style5>Staff No</td></span>"; echo "<td align=center><span class=style5>Details</td></span>"; echo "<td align=center><span class=style5>Amount</td></span>"; echo "<td align=center><span class=style5>GL code</td></span>"; echo "<td align=center colspan=3><span class=style5>Account No. </td></span>"; echo "<td align=center colspan=3><span class=style5>Total </td></span></tr>"; while($myrow = mysql_fetch_row($result)) { echo "<tr><td><span class=style2>" . $myrow[0] . "</span</td>"; echo "<td><span class=style2>" . $myrow[1] . "</span</td>"; echo "<td><span class=style2>" . $myrow[2] . "</td></span>"; echo "<td><span class=style2>" . $myrow[3] . "</span></td>"; echo "<td><span class=style2>" . $myrow[4] . "</span></td>"; echo "<td><span class=style2>" . $myrow[5] . "</span></td>"; echo "<td><span class=style2>" . $myrow[6] . "</span></td>"; echo "<td><span class=style2>" . $myrow[7] . "</span></td>"; } { $query1 = "SELECT staff_no, SUM(amount) FROM report GROUP BY staff_no "; $result1 = mysql_query($query1, $dblink); while($myrow1 = mysql_fetch_row($result1)) { echo "<td>" .$myrow1[0]. "</td>";} } Quote Link to comment https://forums.phpfreaks.com/topic/75884-error-please-help/ Share on other sites More sharing options...
kevincro Posted November 3, 2007 Share Posted November 3, 2007 I'm having a hard time understanding what it is you are trying to calculate. I'm thinking you are wanting to take certain info from other fields in the db, and put them into a certain equation to output an amount. Could you please clarify? Quote Link to comment https://forums.phpfreaks.com/topic/75884-error-please-help/#findComment-384068 Share on other sites More sharing options...
june_c21 Posted November 3, 2007 Author Share Posted November 3, 2007 Example of the report i want Staff No Name Amount Total Amount 123 A 20 20 123 A 30 50 123 B 30 30 Quote Link to comment https://forums.phpfreaks.com/topic/75884-error-please-help/#findComment-384069 Share on other sites More sharing options...
kevincro Posted November 3, 2007 Share Posted November 3, 2007 Does it give you an error message and if so what does it say? Quote Link to comment https://forums.phpfreaks.com/topic/75884-error-please-help/#findComment-384070 Share on other sites More sharing options...
june_c21 Posted November 3, 2007 Author Share Posted November 3, 2007 no.. it just can't output the total column Quote Link to comment https://forums.phpfreaks.com/topic/75884-error-please-help/#findComment-384073 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.