webguync
April 3rd, 2009, 12:46 PM
Hi,
I have an HTML table with extracted data from a MySQL table and I still need to figure out one more thing.
What I have is a set of scores uploaded via an application into the DB, and I want to have a column based on when they were created (earliest to latest) which adds a 1-4 into that column. I already have a column which captures the date created, so I am hoping this will be fairly easy. I want the 1-4 to start over whenever there is a different four letters in the employee_id column, so it would order 1-4 for someone with an employee ID of ADEC, and then start over 1-4, with an employeeID of ADKI.
to help better understand here is the code I have thus far. Everything work well, just need to add the extra column with data I mention above.
<html>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Scores</title>
<link href="report.css" rel="stylesheet" type="text/css" />
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
</head>
<body>
<?php
$con = mysql_connect("localhost","username","pw");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("nnprinceton_p1", $con);
$result = mysql_query("SELECT *
FROM tablename ORDER BY employee_id");
echo "<table>
<tr>
<th>Score ID</th>
<th>Employee ID</th>
<th>Employee Name</th>
<th>score 1</th>
<th>score 2</th>
<th>score 3</th>
<th>score 4</th>
<th>score 5</th>
<th>score 6</th>
<th>Assessor Name</th>
<th>Assessor ID</th>
<th>Call Number (1-4)</th>
<th>Date Created</th>
<th>Date Uploaded</th>
</tr>";
while($row = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['score_id'] . "</td>";
echo "<td>" . $row['employee_id'] . "</td>";
echo "<td>" . $row['employee_name'] . "</td>";
echo "<td>" . $row['score1'] . "</td>";
echo "<td>" . $row['score2'] . "</td>";
echo "<td>" . $row['score3'] . "</td>";
echo "<td>" . $row['score4'] . "</td>";
echo "<td>" . $row['score5'] . "</td>";
echo "<td>" . $row['score6'] . "</td>";
echo "<td>" . $row['assessor_name'] . "</td>";
echo "<td>" . $row['assessor_id'] . "</td>";
echo "<td>" . $row['Need code to increment 1-4 based on date_created and employee_id'] . "</td>";
echo "<td>" . $row['date_created'] . "</td>";
echo "<td>" . $row['date_uploaded'] . "</td>";
echo "</tr>";
}
echo "</table>";
mysql_close($con);
?>
</body>
</html>
I have an HTML table with extracted data from a MySQL table and I still need to figure out one more thing.
What I have is a set of scores uploaded via an application into the DB, and I want to have a column based on when they were created (earliest to latest) which adds a 1-4 into that column. I already have a column which captures the date created, so I am hoping this will be fairly easy. I want the 1-4 to start over whenever there is a different four letters in the employee_id column, so it would order 1-4 for someone with an employee ID of ADEC, and then start over 1-4, with an employeeID of ADKI.
to help better understand here is the code I have thus far. Everything work well, just need to add the extra column with data I mention above.
<html>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Scores</title>
<link href="report.css" rel="stylesheet" type="text/css" />
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
</head>
<body>
<?php
$con = mysql_connect("localhost","username","pw");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("nnprinceton_p1", $con);
$result = mysql_query("SELECT *
FROM tablename ORDER BY employee_id");
echo "<table>
<tr>
<th>Score ID</th>
<th>Employee ID</th>
<th>Employee Name</th>
<th>score 1</th>
<th>score 2</th>
<th>score 3</th>
<th>score 4</th>
<th>score 5</th>
<th>score 6</th>
<th>Assessor Name</th>
<th>Assessor ID</th>
<th>Call Number (1-4)</th>
<th>Date Created</th>
<th>Date Uploaded</th>
</tr>";
while($row = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['score_id'] . "</td>";
echo "<td>" . $row['employee_id'] . "</td>";
echo "<td>" . $row['employee_name'] . "</td>";
echo "<td>" . $row['score1'] . "</td>";
echo "<td>" . $row['score2'] . "</td>";
echo "<td>" . $row['score3'] . "</td>";
echo "<td>" . $row['score4'] . "</td>";
echo "<td>" . $row['score5'] . "</td>";
echo "<td>" . $row['score6'] . "</td>";
echo "<td>" . $row['assessor_name'] . "</td>";
echo "<td>" . $row['assessor_id'] . "</td>";
echo "<td>" . $row['Need code to increment 1-4 based on date_created and employee_id'] . "</td>";
echo "<td>" . $row['date_created'] . "</td>";
echo "<td>" . $row['date_uploaded'] . "</td>";
echo "</tr>";
}
echo "</table>";
mysql_close($con);
?>
</body>
</html>