Create HTML table based on Database Values - php

I have a database that has information on actors, roles, and movies.
On an HTML page I have the user input the first name and last name of an actor.
This form is then submitted to my PHP page where I look through my database, and provide the user with a 3 column html table with the following information: Movie Name the actor has worked in, Role the actor played, and year of movie.
All these information are in separate database tables. Examples of what each table looks like is below:
actor table contains:
'id', 'first_name', 'last_name', and 'gender' stored in the following way - (933,'Actor','Name','M')
role table contains:
'actor_id', 'movie_id', 'role stored in the following way - (16844,10920,'Role')
movies table contains:
'id', 'name', 'year', 'rank' stored in the following way - (306032,'Snatch.',2000,7.9)
I have to look through and correlate all the data into a table. This is what I have so far:
$sql ="SELECT id, first_name, last_name FROM actors";
$result = mysql_query($sql);
while($row=mysql_fetch_array($result)) {
if ($row['first_name'] == $firstname && $row['last_name'] == $lastname) {
$actorID = $row['id'];
echo "$actorID<br>";
}
}//end while
$sql2 = "SELECT actor_id, movie_id, role FROM roles";
$result2 = mysql_query($sql2);
while ($row=mysql_fetch_array($result2)) {
if ($row['actor_id'] == $actorID) {
$movieID = $row['movie_id'];
$actRole = $row['role'];
echo "$movieID <br>";
echo "$actRole <br>";
}
} //end while
$sql3 = "SELECT id, name, year FROM movies";
$result3 = mysql_query($sql3);
while ($row=mysql_fetch_array($result3)) {
if ($row['id'] == $movieID) {
$movieName = $row['name'];
$movieYear = $row['year'];
echo "$movieName <br>";
echo "$movieYear <br>";
}
} //end while
echo '
<table>
<thead>
<tr>
<th> Movie Name </th>
<th> Actor Role </th>
<th> Release Date </th>
</tr>
</thead>
<tbody>
<td>'. $movieName .'</td>
<td>'. $actRole. '</td>
<td>'. $movieYear. '</td>
</tbody>
</table>';
?>
My solution works -- just a mediocre way of doing it

You don't have assign the variables $firstname and $lastname. Apart from that your if condition is wrong true every time.
if ($row['first_name'] = $firstname && $row['last_name'] = $lastname) {
Should be:
if ($row['first_name'] == $firstname && $row['last_name'] == $lastname) {
Also check what you want to do with the echo $row['first_name'][0];
Note that mysql_* functions are deprecated so you better use mysqli or PDO.
EDIT:
You can select all actors that have play in a movie using the following query. You can adjust to take only the information you need changing SELECT clause or using WHERE.
$sql = "
SELECT aa.id AS actor_id, aa.first_name, aa.last_name, cc.name, cc.year
FROM actor AS aa
INNER JOIN role AS bb
ON aa.id = bb.actor_id
INNER JOIN movies AS cc
ON cc.id = bb.movie_id";
EDIT 2: (from comments)
You can use the following code:
$conn = mysqli_connect("localhost", "db_username", "your_password", "your_database");
$query = "
SELECT aa.id AS actor_id, aa.first_name, aa.last_name, cc.name AS movie_name, cc.year AS release_year
FROM actor AS aa
INNER JOIN role AS bb
ON aa.id = bb.actor_id
INNER JOIN movies AS cc
ON cc.id = bb.movie_id";
$result = mysqli_query($conn, $query);
echo '
<table>
<thead>
<tr>
<th>Actor id</th>
<th>Firstname</th>
<th>Lastname</th>
<th>Movie name</th>
<th>Release date</th>
</tr>
</thead>
<tbody>';
while($row = mysqli_fetch_array($result)) {
echo '<td>'.$row['actor_id'].'</td>';
echo '<td>'.$row['first_name'].'</td>';
echo '<td>'.$row['last_name'].'</td>';
echo '<td>'.$row['movie_name'].'</td>';
echo '<td>'.$row['release_year'].'</td>';
}
echo '
</tbody>
</table>';

Related

Compare two results and show results PHP

I'm trying to get two identical IDs and turn them into a name, explaining better I have a table with ID-COMPANY NAME and in the product table ID COMPANY - product name, I would like to match the two and next i will output in excel file.
I tested this code but all the results do not appear to me:
while(($row = mysqli_fetch_array($result)) && ($row2 = mysqli_fetch_array($result2)) )
{
For answer:
db:
1) id - name company - ecc //Table company
2) id_product - product - id_company //Table product
Output excel:
Client 1 - id
Client 2 - id
Name | another information
Client 1 | ecc...
Client 2 | ecc...
Php:
$result = mysqli_query($connect, $query); // FIRST CONNECT TABLE
$result2 = mysqli_query($connect, $query2); // SECOND CONNECT TABLE
if(mysqli_num_rows($result2) && mysqli_num_rows($result)> 0)
{
$output2 .= '
<table class="table" id="table" bordered="1">
';
while($row2 = mysqli_fetch_array($result2))
{
$output2 .= '
<tr>
<td class="grassetto">Company:</td>
<td class="grassetto">'. $row2["id"].'-'. $row2["nomeazienda"].'</td>
</tr>
<tr>
<td class="grassetto">ID:</td>
<td class="grassetto">'. $mese.'/'.$anno.'</td>
</tr>
';
}
$output2 .= '</table>';
$output .= '
<table class="table ops" id="table" border="1">
<tr>
<th>Name Company</th>
<th>Another information</th>
</tr>
';
while($row = mysqli_fetch_array($result))
{
$output .= '
<tr>
<td align="left">'. $row['id_azienda'] . '</td>
<td align="left">'. $row['nr'] . '</td>
</tr>
';
}
$output .= '</table>';
header('Content-Type: application/xls');
header('Content-Disposition: attachment; filename=download.xls');
header("Pragma: no-cache");
header("Expires: 0");
echo $output2. "\n<br>" .$output."\n";
}
So in second output when i call $result i need to compare ID/ID_COMPANY and write a company name
Edit 2:
That is main query
$query = 'SELECT * FROM products WHERE id_company in ('.$company.') AND product ="'.$products.'"';
}else{
$query = 'SELECT * FROM products WHERE id_company IN ('.$company.') AND product ="'.$products.'" AND last_check LIKE "%'.$anno.'-'.$mese.'%"';
}
$query2 = 'SELECT * FROM company WHERE id in ('.$company.')';
how do you integrate this code?
Use a simple JOIN to get the company name from the company ID in the product table in a single query.
$query = "
SELECT c.name, p.product, ...
FROM company AS c
JOIN product AS p ON c.id = p.id_company
WHERE c.id in ($company) AND p.product = '$product'";

Student Attendance Report within a PIVOT Table

I am trying to record the attendance of my students that attend my courses. Courses are different lengths and times and I just need to record if a student is (P)resent (L)ate (A)sent. I record the attendance in 1 table and display the records in a pivot table based on the date attended. I am a newby and just can't workout this code to include all the details I need to show. id, bid, fullname, nickname, company_idno, (P)(L)(A).
Please could someone look at my code and tell me how to add this information to the pivot table.
This is what I want to show
This is where I store the information
This is table1
This is table2
At the moment I achieved the look I want but use 2 tables and use CSS to fix the widths of table 1 and place table 2 next to it.
I realize this is terrible practice and of course, I get odd results across different platforms, especially iOS which put a 47px gap between the 2 tables which I can't seem to remove also.
I want just want table 2 to show all the information. I can only show 3 fields, id, date, pla. How to add fullname, nickname and company_idno ??
Table 1
<table id="tblplanames" >
<td id="tdplabc">sid</td>
<td id="tdplabc">bid</td>
<td id="tdplacid" style="text-align: center">Cid</td>
<td id="tdplafn" style="text-align: center">Fullname</td>
<td id="tdplann" style="text-align: center">Nickname</td>
<?php
$sql13="SELECT * FROM students WHERE classno='$id' ORDER BY bluecard_no ASC ";
$sql_row13=mysqli_query($link,$sql13);
while($sql_res13=mysqli_fetch_assoc($sql_row13)) {
$stsid=$sql_res13["id"];
$stidno=$sql_res13["company_idno"];
$stbluecard_no=$sql_res13["bluecard_no"];
$stfullname=$sql_res13["fullname"];
$stnickname=$sql_res13["nickname"];
?>
<tr>
<td id="tdplabc"><a href=edit_student.php?id=<?php echo $stsid ?>><?php echo $stsid; ?></td>
<td id="tdplabc"><a href=edit_student.php?id=<?php echo $stsid ?>><?php echo $stbluecard_no; ?></td>
<td id="tdplacid"><a href=edit_student.php?id=<?php echo $stsid ?>><?php echo $stidno; ?></td>
<td id="tdplafn"><a href=edit_student.php?id=<?php echo $stsid ?>><?php echo $stfullname; ?></td>
<td id="tdplann"><a href=edit_student.php?id=<?php echo $stsid ?>><?php echo $stnickname; ?></td>
</tr>
<?php
}
?>
</table>
Table 2
<?php
$id = $_GET['id'];
$sql = "SELECT DISTINCT date
FROM attendance
WHERE classno = $id
ORDER BY DATE";
$res = $link->query($sql); // mysqli query
while ($row = $res->fetch_row()) {
$dates[] = $row[0];
}
/***********************************
* Table headings *
************************************/
$emptyRow = array_fill_keys($dates,'');
// format dates
foreach ($dates as $k=>$v) {
$dates[$k] = date('d-M', strtotime($v));
}
$heads = "<table id='tblpla'>\n";
$heads .= "<tr><td>sid</td><td>" . join('</td><td>', $dates) . "</td></tr>\n";
/***********************************
* Main data *
************************************/
$sql = "SELECT date, sid, pla, bluecard_no
FROM attendance
WHERE classno = $id
ORDER BY bluecard_no";
$res = $link->query($sql);
$sid='';
$tdata = '';
while (list($d, $sn, $s, $bcn) = $res->fetch_row()) {
if ($sid != $sn) {
if ($sid) {
$tdata .= "<tr><td>$sid</td><td>" . join('</td><td>', $rowdata). "</td></tr>\n";
}
$rowdata = $emptyRow;
$sid = $sn;
}
$rowdata[$d] = $s;
}
$tdata .= "<tr><td>$sid</td><td>" . join('</td><td>', $rowdata). "</td></tr>\n";
$tdata .= "</table\n";
echo $heads;
echo $tdata;
?>
SELECT c.olumns
, y.ou
, a.ctually
, w.ant
FROM students s
JOIN attendance a
ON a.classno = s.classno
WHERE s.classno = :id
ORDER
BY s.bluecard_no ASC
, a.date";
public function get_members_for_attendence()
{
$date = $this->input->post('choose_date');
$sql = 'SELECT a.date, c.member_name,c.member_join_date,c.member_payment_date,c.member_exp_date,c.member_payment_date,c.member_contact, c.member_reg_id,
CASE
WHEN a.status = "absent" THEN "Absent"
WHEN a.status = "present" THEN "Present"
ELSE "Not Taken"
END as attendence_status
FROM member_reg AS c
LEFT JOIN attendence AS a ON a.member_reg_id = c.member_reg_id AND a.date = "'.$date.'"';
$query = $this->db->query($sql);
return $query->result();
}
For CodeIgniter 3
it worked for me

SQL calculate row number

I doing league table football and There is a profile of Team (Like : Team.php?team=XXX)
In this page I want to show, What position of TeamXXX in League Table
Page League Table
<?php
$number = 0;
$sql = "SELECT * FROM `leaguetable` WHERE `league` = 'leaguename' ORDER BY pts DESC";
$query = mysql_query($sql);
while($rs=mysql_fetch_assoc($query)){
$number++;
?>
<table>
<thead>
<tr>
<th>Position</th>
<th>Team</th>
<th>Points</th>
</tr>
</thead>
<tbody>
<td><?php echo $number; ?></td>
<td><?php echo $rs['team']; ?></td>
<td><?php echo $rs['pts']; ?></td>
</tbody>
</table>
<?php } ?>
Data in Table leaguetable
id team pts
In team.php I want to show position of TeamXXX
<?php
$getTeam = mysql_fetch_assoc(mysql_query("SELECT * FROM `leaguetable` WHERE `team`='"$_GET['team']"'");
?>
<table>
<thead>
<tr>
<th>Position</th>
<th>Team</th>
<th>Points</th>
</tr>
</thead>
<tbody>
<td>#########</td>
<td><? echo $getTeam['team']; ?></td>
<td><? echo $getTeam['pts']; ?></td>
</tbody>
</table>
How can I know what position of teamXXX in leaguetable?
Any help will be greatly appreciated. Thank you very much
query
select id, team, pts, rnk
from
(
select leag.id, leag.team, leag.pts,
#rnk := if(leag.pts = #lag, #rnk,
if(#lag := leag.pts, #rnk + 1, #rnk + 1)) as rnk
from leaguetable leag
cross join ( select #rnk := 0, #lag := null ) params
where league = 'FA Cup'
order by leag.pts desc
) rankings
where team = 'Chelsea'
;
example.php
<?php
/**
* Mysqli initial code
*
* User permissions of database
* Create, Alter and Index table, Create view, and Select, Insert, Update, Delete table data
*
* #package PhpFiddle
* #link http://phpfiddle.org
* #since 2012
*/
require_once "dBug!.php";
require "util/public_db_info.php";
$short_connect = new mysqli($host_name, $user_name, $pass_word, $database_name, $port);
if (mysqli_connect_errno())
{
die("Failed to connect to MySQL: " . mysqli_connect_error());
}
/*
$sql = "create table leaguetable"
. "("
. " id integer primary key not null,"
. " team varchar(33) not null,"
. " pts integer not null default 0"
. ");";
$result = $short_connect->query($sql);
if(!$result)
{
die("Create table failed : " . mysqli_error($short_connect));
}
$sql = "insert into leaguetable"
. "( id, team, pts )"
. "values"
. "( 1, 'Liverpool', 22 ),"
. "( 2, 'Arsenal', 29 ),"
. "( 3, 'Chelsea', 23 ),"
. "( 4, 'Tottenham', 23)";
$result = $short_connect->query($sql);
if(!$result)
{
die("insert failed : " . mysqli_error($short_connect));
}
*/
//get all tables in the database
//$sql = "SHOW TABLES";
//get column information from a table in the database
//$sql="SELECT COLUMN_KEY, COLUMN_NAME, COLUMN_TYPE FROM information_schema.COLUMNS WHERE TABLE_NAME = 'books'";
//SQL statement for a table in the database
$sql = "select id, team, pts, rnk "
. "from"
. "("
. "select leag.id, leag.team, leag.pts,"
. "#rnk := if(leag.pts = #lag, #rnk,"
. " if(#lag := leag.pts, #rnk + 1, #rnk + 1)) as rnk "
. "from leaguetable leag "
. "cross join ( select #rnk := 0, #lag := null ) params "
. " where league = 'FA Cup' "
. "order by leag.pts desc;"
. ") rankings "
. where team = 'Chelsea';";
//result is boolean for query other than SELECT, SHOW, DESCRIBE and EXPLAIN
$result = $short_connect->query($sql);
if (($result) && ($result->num_rows > 0))
{
echo "<table>" . "<thead>" . "<tr>" . "<th>Position</th>" . "<th>Team</th>" . "<th>Points</th>" . "</tr>" . "</thead>" . "<tbody>";
//convert query result into an associative array
echo "<tr><td>" . $row['rnk'] . "</td><td>" . $row['team'] . "</td><td>" . $row['pts'] . "</td></tr>";
echo "</tbody></table>";
}
else
{
die("select failed : " . mysqli_error($short_connect));
}
$short_connect->close();
?>
output
<table>
<thead>
<tr>
<th>Position</th>
<th>Team</th>
<th>Points</th>
</tr>
</thead>
<tbody>
<tr>
<td>2</td>
<td>Chelsea</td>
<td>23</td>
</tr>
</tbody>
</table>
sqlfiddle
Hope this will help
$number = 0;
$points=0;
$sql = "SELECT * FROM `leaguetable` WHERE `league` = 'leaguename' ORDER BY pts DESC";
$query = mysql_query($sql);
while($rs=mysql_fetch_assoc($query)){
if($points!=$rs['pts'])
$number++;
if($rs['team']==$_GET['team']){
if($points==$rs['pts'])
$position=$number-1;
else
$position=$number;
}
$poins=$rs['pts'];
}
If you don't mind using two queries (I wouldn't mind it), it's pretty easy: Just count how many teams have more points, and add one (so that if three teams are tied in second position, they all get position 2).
$result = mysql_query("SELECT count(*)+1 AS POSTN FROM leaguetable WHERE
league = 'leaguename' AND pts > $points");
$row = mysql_fetch_assoc($result);
$position = $row["POSTN"];
Doing it in one query is a bit messier, since you need to embed this query in your original one:
"SELECT *, (SELECT count(*)+1 FROM leaguetable table2
WHERE league = 'leaguename' AND table2.pts > leaguetable.pts) AS POSTN
FROM leaguetable WHERE team = '$currentteam'"
But why are you using the mysql_* API for new code? Haven't you noticed all the dire warnings in pink boxes in the documentation? Do yourself a favor and switch to mysqli today, starting with this program.
Also: Never just inject $_GET[param] into your query string! You're giving yourself an SQL injection attack waiting to happen... and brittle, error-prone code until then.

PHP/MYSQL - "ORDER BY" Doesn't work

I have a table with a bunch of users who have a certain amount of points. I would like to arrange the users from highest points first to the lowest. However ORDER BY PTS DESC doesn't work.
<tr>
<th id="users_th1"><img src="<?php echo mysql_result($r_TEAMS, $i, 'LOGO'); ?>"/> <p><?php echo mysql_result($r_TEAMS, $i, 'NAME'); ?></p></th>
<th id="users_th2">Points Value</th>
</tr>
<?php
$q_users = 'Select * from POINTS LEFT JOIN USERS on USERS.UID = POINTS.UID where TID = '.mysql_result($r_TEAMS, $i, 'TID');
$r_users = mysql_query($q_users, $connection) or die(mysql_error());
$n_users = mysql_num_rows($r_users);
for($k = 0; $k <$n_users; $k++){
?>
<tr>
<td class="person"><?php echo mysql_result($r_users, $k, 'NAME'); ?></td>
<td><?php echo mysql_result($r_users, $k, 'POINTS.PTS'); ?></td>
</tr>
<?php
}
}
This is just guesswork, but I see you're doing a JOIN between the table USER and the table POINTS. Perhaps you have a field called PTS in both tables, so if you want to order the results by that field you should indicate to which table the one you're referring to belongs.
So, do it this way,
$q_users = "
SELECT *
FROM POINTS
LEFT JOIN USERS
ON USERS.UID = POINTS.UID
WHERE <table name>.TID = " . mysql_result($r_TEAMS, $i, 'TID') . "
ORDER BY <table name>.PTS DESC";
Did you try:
$q_users = 'Select * from POINTS LEFT JOIN USERS on USERS.UID = POINTS.UID where TID = '.mysql_result($r_TEAMS, $i, 'TID').' ORDER BY PTS DESC;';
You could also write if it won't sort or if it won't query.

Count the total of a specific value in mysql/php

I have a table which has a field isClaimed that has only two fixed values = CLAIMED or NOT CLAIMED. I have to calculate the total of each field.
FYI, assume this is my table:
name | isClaimed
Aye | NOT CLAIMED
Ian | CLAIMED
Jan | NOT CLAIMED
Zen | NOT CLAIMED
Pom | CLAIMED
Total of unclaimed: 3
Total of claimed: 2
And please check my code below:
<?php
$sql = "SELECT pro.ScholarId, pro.Lastname, pro.Middlename, pro.Firstname, pro.Address, levels.LevelName, school.SchoolName, barangays.BarangayName, payroll.Allowance, sp.Points, pro.ScholarPointId, sca.isClaimed
FROM scholar_profile as pro
JOIN scholar_school as school ON pro.SchoolId = school.SchoolId
JOIN levels ON pro.LevelId = levels.LevelId
JOIN barangays ON pro.BarangayId = barangays.BarangayId
JOIN payroll ON payroll.PayrollId = levels.PayrollId
INNER JOIN scholar_points as sp ON pro.ScholarPointId = sp.ScholarPointId
JOIN scholar_claim_allowance as sca ON pro.ScholarId = sca.ScholarId
ORDER BY pro.LevelId, pro.ScholarId";
// OREDER BY id DESC is order result by descending
$result2 = mysql_query($sql);
if($result2 === FALSE) {
die(mysql_error()); // TODO: better error handling
}
// Start looping table row
while ($row2 = mysql_fetch_array($result2)) {
$firstname = $row2["Firstname"];
$lastname = $row2["Lastname"];
$middlename = $row2["Middlename"];
$barangay = $row2["BarangayName"];
$level = $row2["LevelName"];
$allowance = $row2["Allowance"];
$isClaimed = $row2["isClaimed"];
?>
<tr>
<td class="spec"><?php echo $lastname.", ".$firstname. " " .substr($middlename, 0,1) . "." ; ?> </td>
<td><?php echo $barangay; ?></td>
<td><?php echo $level; ?></td>
<td><?php echo $allowance; ?></td>
<td><?php echo $isClaimed ?></td>
</tr>
<?php
// Exit looping
}
?>
<tr>
<td colspan="4" class="spec">Total of unclaimed allowances</td>
<td></td>
</tr>
<tr>
<td colspan="4" class="spec">Total of claimed allowances</td>
<td></td>
</tr>
I have tried the tutorial from here: http://www.randomsnippets.com/2008/10/05/how-to-count-values-with-mysql-queries/
But i can't get it to work in php.
From the tutorial you linked....
$sql = "SELECT
SUM(IF(sca.isClaimed = "CLAIMED", 1,0)) AS claimedTotal,
SUM(IF(sca.isClaimed = "NOT CLAIMED", 1,0)) AS notClaimedTotal,
pro.ScholarId, pro.Lastname, pro.Middlename, pro.Firstname, pro.Address, levels.LevelName,
school.SchoolName, barangays.BarangayName, payroll.Allowance, sp.Points, pro.ScholarPointId, sca.isClaimed
FROM scholar_profile as pro
JOIN scholar_school as school ON pro.SchoolId = school.SchoolId
JOIN levels ON pro.LevelId = levels.LevelId
JOIN barangays ON pro.BarangayId = barangays.BarangayId
JOIN payroll ON payroll.PayrollId = levels.PayrollId
INNER JOIN scholar_points as sp ON pro.ScholarPointId = sp.ScholarPointId
JOIN scholar_claim_allowance as sca ON pro.ScholarId = sca.ScholarId
ORDER BY pro.LevelId, pro.ScholarId";
And then
echo $row2["claimedTotal"];
and
echo $row2["notClaimedTotal"];
Note that I used the table sca for for the isClaimed value, just a guess...not sure of your table structure, maybe you will need to change sca to reflect the correct table.
<?php
$claimedCount = 0;
$unclaimedCount= 0;
$sql = "SELECT pro.ScholarId, pro.Lastname, pro.Middlename, pro.Firstname, pro.Address, levels.LevelName, school.SchoolName, barangays.BarangayName, payroll.Allowance, sp.Points, pro.ScholarPointId, sca.isClaimed
FROM scholar_profile as pro
JOIN scholar_school as school ON pro.SchoolId = school.SchoolId
JOIN levels ON pro.LevelId = levels.LevelId
JOIN barangays ON pro.BarangayId = barangays.BarangayId
JOIN payroll ON payroll.PayrollId = levels.PayrollId
INNER JOIN scholar_points as sp ON pro.ScholarPointId = sp.ScholarPointId
JOIN scholar_claim_allowance as sca ON pro.ScholarId = sca.ScholarId
ORDER BY pro.LevelId, pro.ScholarId";
// OREDER BY id DESC is order result by descending
$result2 = mysql_query($sql);
if($result2 === FALSE) {
die(mysql_error()); // TODO: better error handling
}
// Start looping table row
while ($row2 = mysql_fetch_array($result2)) {
$firstname = $row2["Firstname"];
$lastname = $row2["Lastname"];
$middlename = $row2["Middlename"];
$barangay = $row2["BarangayName"];
$level = $row2["LevelName"];
$allowance = $row2["Allowance"];
$isClaimed = $row2["isClaimed"];
?>
<tr>
<td class="spec"><?php echo $lastname.", ".$firstname. " " .substr($middlename, 0,1) . "." ; ?> </td>
<td><?php echo $barangay; ?></td>
<td><?php echo $level; ?></td>
<td><?php echo $allowance; ?></td>
<td><?php echo $isClaimed ?></td>
</tr>
<?php
if($row2["isClaimed"] == "CLAIMED")
$claimedCount++;
elseif($row2["isClaimed"] == "NOT CLAIMED")
$unclaimedCount++;
// Exit looping
}
?>
<tr>
<td colspan="4" class="spec">Total of unclaimed allowances</td>
<td><?php echo $unclaimedCount;?></td>
</tr>
<tr>
<td colspan="4" class="spec">Total of claimed allowances</td>
<td><?php echo $claimedCount;?></td>
</tr>
Note: I have not checked you query. I have just mentioned my suggestion about getting the count that suits your current structure. Moreover, its highly recommended to start using mysqli_* instead of mysql.

Categories