So I need to fetch data such as section, item names and subtotal of every section from my database and get the grand total of all the items.
I stumble upon the code below and modify it to my requirements.
The code works perfectly but I need to display more data like Item description, Qty, Price, status and so on.
The code below works and have no problem whatsoever but i need more data (description, qty, price and so on) to display in my table but I can't figure out how to do it.
The data I need to display is also in the same row where projectscostbreakdown_areaname, projectscostbreakdown_itemname and projectscostbreakdown_totalcost are.
<?php
$projectsid = $_GET['projectrfpid'];
$itemdeleted = 1;
$itemfirstothers = 'OTHERS';
$query = $conn->prepare('SELECT projectscostbreakdown_id,
projectscostbreakdown_projectid,
projectscostbreakdown_areaname,
projectscostbreakdown_itemname,
projectscostbreakdown_itemdescription,
projectscostbreakdown_qty,
projectscostbreakdown_costpiece,
projectscostbreakdown_budgeted,
projectscostbreakdown_totalcost,
projectscostbreakdown_note,
projectscostbreakdown_addedby,
projectscostbreakdown_addeddate,
projectscostbreakdown_deleted,
projectscostbreakdown_lastedit,
projectscostbreakdown_lasteditby
FROM projectscostbreakdown WHERE projectscostbreakdown_projectid=:projectsid && projectscostbreakdown_deleted=:itemdeleted ORDER BY projectscostbreakdown_areaname=:itemfirstothers, projectscostbreakdown_areaname ASC, projectscostbreakdown_id DESC');
$query->bindParam(':projectsid', $projectsid, PDO::PARAM_INT);
$query->bindParam(':itemdeleted', $itemdeleted, PDO::PARAM_INT);
$query->bindParam(':itemfirstothers', $itemfirstothers, PDO::PARAM_INT);
$query->execute();
$data = array();
$data2 = array();
$numbering = 0; //for item count
$count = 1; //counter use for background color
while ( $row2 = $query->fetch() ) {
if ( empty($data[ $row2['projectscostbreakdown_areaname'] ]) ) {
$data[ $row2['projectscostbreakdown_areaname'] ]= array();
$data2[ $row2['projectscostbreakdown_itemdescription'] ][ $row2['projectscostbreakdown_qty'] ]= array();
}
if ( empty( $data[ $row2['projectscostbreakdown_areaname'] ][ $row2['projectscostbreakdown_itemname'] ] ) ) {
$data[ $row2['projectscostbreakdown_areaname'] ][ $row2['projectscostbreakdown_itemname'] ] = array();
$data2[ $row2['projectscostbreakdown_itemdescription'] ][ $row2['projectscostbreakdown_qty'] ]= array();
}
$data[ $row2['projectscostbreakdown_areaname'] ][ $row2['projectscostbreakdown_itemname'] ][] = $row2['projectscostbreakdown_totalcost'];
$data2[ $row2['projectscostbreakdown_itemdescription'] ][ $row2['projectscostbreakdown_qty'] ]= array();
}
print '<table width="100%" border="0"><tbody>';
$totalSum = 0;
foreach ( $data as $area => $item ) {
print '<tr style="background-color: white;"><td colspan="7" style="text-align: left;"><br /><br /><b><u>'. $area .'</u></b></td></tr>';
print '<tr style="background-color: #AAAAAA; text-align: center;">
<td width="20%""><b>Item name</b></td>
<td width="30%"><b>Description</b></td>
<td width="5%"><b>Qty.</b></td>
<td width="10%"><b>Cost/Piece</b></td>
<td width="10%"><b>Subtotal</b></td>
<td width="10%"><b>Budget</b></td>
<td width="15%"><b>Note /<br / >Entered by</b></td>
</tr>';
$totalArea = 0;
foreach ( $item as $item => $totalcost ) {
//while ( $data = $query->fetch() ) {
$numbering++;
$count++;
$class = ($count%2 == 0)? 'white': '#CCCCCC';
$sum = array_sum( $totalcost );
print '<tr style="background-color: '.$class.'">';
print '<td style="vertical-align: top; text-align: left;">'. $numbering .'. '. $item . '</td>';
print '<td style="vertical-align: top; text-align: left;">';
print_r($data2);
print '</td>';
print '<td style="vertical-align: top; text-align: right;"></td>';
print '<td style="vertical-align: top; text-align: right;"></td>';
print '<td style="vertical-align: top; text-align: right;">'. number_format($sum, 2,'.', ',') . '</td>';
print '<td style="vertical-align: top; text-align: right;"></td>';
print '<td style="vertical-align: top; text-align: left;"></td>';
print '</tr>';
$totalArea += $sum;
}
print '<tr style="background-color: lightgray; text-align: right;" ><td colspan="6">Section Total: </td><td>'. number_format($totalArea, 2,'.', ',') . '</td></tr>';
$totalSum += $totalArea;
}
print '<tr style="background-color: lightblue; text-align: right;" ><td colspan="6"><b>Grand Total: </b></td><td><b>'. number_format($totalSum, 2,'.', ',') . '</b></td></tr>';
echo '</tbody>
</table>';
?>
UPDATE
The output looks like this right now.
I need to include Description and Qty in the output but cant figure how to be done.
Section1
Item Name-----Description-----Qty-----Subtotal
item 1---------------------------------------------1000
item 2---------------------------------------------2000
----------------------------------Section Total: 3000
Section2
Item Name-----Description-----Qty-----Subtotal
item 3---------------------------------------------1000
----------------------------------Section Total: 1000
------------------------------------Grand Total: 4000
Complete code (more structured, fixed bugs):
<?php
$projectsid = $_GET['projectrfpid'];
$itemdeleted = 1;
$itemfirstothers = 'OTHERS';
$query = $conn->prepare('SELECT projectscostbreakdown_id,
projectscostbreakdown_projectid,
projectscostbreakdown_areaname,
projectscostbreakdown_itemname,
projectscostbreakdown_itemdescription,
projectscostbreakdown_qty,
projectscostbreakdown_costpiece,
projectscostbreakdown_budgeted,
projectscostbreakdown_totalcost,
projectscostbreakdown_note,
projectscostbreakdown_addedby,
projectscostbreakdown_addeddate,
projectscostbreakdown_deleted,
projectscostbreakdown_lastedit,
projectscostbreakdown_lasteditby
FROM projectscostbreakdown WHERE projectscostbreakdown_projectid=:projectsid && projectscostbreakdown_deleted=:itemdeleted ORDER BY projectscostbreakdown_areaname=:itemfirstothers, projectscostbreakdown_areaname ASC, projectscostbreakdown_id DESC');
$query->bindParam(':projectsid', $projectsid, PDO::PARAM_INT);
$query->bindParam(':itemdeleted', $itemdeleted, PDO::PARAM_INT);
$query->bindParam(':itemfirstothers', $itemfirstothers, PDO::PARAM_INT);
$query->execute();
$data = array();
$data2 = array();
$numbering = 0; //for item count
$count = 1; //counter use for background color
$itemData = $query->fetchAll();
$query->execute();
while ($row2 = $query->fetch()) {
if (empty($data[$row2['projectscostbreakdown_areaname']]) ) {
$data[$row2['projectscostbreakdown_areaname']]= array();
$data2[$row2['projectscostbreakdown_itemdescription']][$row2['projectscostbreakdown_qty']] = array();
}
if (empty($data[$row2['projectscostbreakdown_areaname']][$row2['projectscostbreakdown_itemname']])) {
$data[$row2['projectscostbreakdown_areaname']][ $row2['projectscostbreakdown_itemname']] = array();
$data2[$row2['projectscostbreakdown_itemdescription']][$row2['projectscostbreakdown_qty']]= array();
}
$data[$row2['projectscostbreakdown_areaname']][$row2['projectscostbreakdown_itemname']][] = $row2['projectscostbreakdown_totalcost'];
$data2[$row2['projectscostbreakdown_itemdescription']][$row2['projectscostbreakdown_qty']] = array();
}
print '<table width="100%" border="0"><tbody>';
$totalSum = 0;
foreach ( $data as $area => $item ) {
print '<tr style="background-color: white;"><td colspan="7" style="text-align: left;"><br /><br /><b><u>'. $area .'</u></b></td></tr>';
print '<tr style="background-color: #AAAAAA; text-align: center;">
<td width="20%""><b>Item name</b></td>
<td width="30%"><b>Description</b></td>
<td width="5%"><b>Qty.</b></td>
<td width="10%"><b>Cost/Piece</b></td>
<td width="10%"><b>Subtotal</b></td>
<td width="10%"><b>Budget</b></td>
<td width="15%"><b>Note /<br / >Entered by</b></td>
</tr>';
$totalArea = 0;
foreach ( $item as $item => $totalcost ) {
$count++;
echo $numbering.' ';
$class = ($count % 2 == 0) ? 'white' : '#CCCCCC';
$sum = array_sum($totalcost);
print '<tr style="background-color: '.$class.'">';
print '<td style="vertical-align: top; text-align: left;">'. $numbering .'. '. $item . '</td>';
print '<td style="vertical-align: top; text-align: left;">'.$itemData[$numbering]['projectscostbreakdown_itemdescription'].'</td>';
print '<td style="vertical-align: top; text-align: right;"></td>';
print '<td style="vertical-align: top; text-align: right;"></td>';
print '<td style="vertical-align: top; text-align: right;">'. number_format($sum, 2,'.', ',') . '</td>';
print '<td style="vertical-align: top; text-align: right;"></td>';
print '<td style="vertical-align: top; text-align: left;"></td>';
print '</tr>';
$numbering++;
$totalArea += $sum;
}
print '<tr style="background-color: lightgray; text-align: right;" ><td colspan="6">Section Total: </td><td>'. number_format($totalArea, 2,'.', ',') . '</td></tr>';
$totalSum += $totalArea;
}
print '<tr style="background-color: lightblue; text-align: right;" ><td colspan="6"><b>Grand Total: </b></td><td><b>'. number_format($totalSum, 2,'.', ',') . '</b></td></tr>';
echo '</tbody></table>';
?>
Basically, what I did (which might not be the best option but I couldn't think anything better) was I used $itemData = $query->fetchAll(); after executing $query->execute();. Now if we leave everything the same, table will be empty since pointer is at the last element. Therefore, we must execute again the same query by writing an additional $query->execute(); right after $itemData = $query->fetchAll();.
Now we have basically the same thing as in your example but with one additional variable $itemData with all information about items. To bring out description, quantity, etc. now we can use $itemData[$numbering]['projectscostbreakdown_itemdescription'] where $numbering stands for array's index number.
Related
thank you in advance for helping me. I am stuck with this problem. I should put different colors of text per row but I only know alternating 2 colors per row. This should be the output
<?php
$color1 = "#32CD32";
$color2 = "#FF0000";
$color3 = "#5e0087";
$color4 = "#FFA500";
$color5 = "#00008b";
$color = NULL;
echo "<table border =\"1\" style='border-collapse: collapse'>";
for ($row=1; $row <= 5; $row++) {
echo "<tr> \n";
$color == $color1 ? $color = $color2: $color = $color1;
for ($col=1; $col <= 4; $col++) {
$num = $col * $row;
echo "<td style = 'color:$color'> $num </td> \n";
}
echo "</tr>";
}
echo "</table>";
?>
You can create dynamic variables in php by creating the string (like "color1" and then putting $$ before it.
$color1 = "#32CD32";
$color2 = "#FF0000";
$color3 = "#5e0087";
$color4 = "#FFA500";
$color5 = "#00008b";
$color = NULL;
echo "<table border =\"1\" style='border-collapse: collapse'>";
for ($row=1; $row <= 5; $row++) {
echo "<tr> \n";
$color = "color".$row;
$color = $$color;
for ($col=1; $col <= 4; $col++) {
$num = $col * $row;
echo "<td style = 'color:$color'> $num </td> \n";
}
echo "</tr>";
}
Here's another option, put the colors in an array
$colors = ["#32CD32", "#FF0000", "#5e0087", "#FFA500", "#00008b"];
then just access the array with the $row #
$color = $colors[$row -1];
You should avoid using individual variables to store related data. By assigning these colors as elements in an array, you afford yourself the ability to loop over the collection of values without the use of "variable variables" (when your script seems to need variable variables, then it is time to rethink your script).
$colors = [
1 => "#32CD32",
2 => "#FF0000",
3 => "#5E0087",
4 => "#FFA500",
5 => "#00008B"
];
You should avoid writing inline styles as much as possible. In truth, I'd recommend that you completely color your rows of text using pure css. However, I get the impression that this is just an exercise in writing dynamic code.
<style>
table {
border-collapse: collapse;
width: 1%;
}
td {
border: solid 1px black;
padding: 8px;
}
</style>
I find myself paying an increasing amount of attention to generating clean well-tabbed source code (in addition to producing clean rendered html). To assist in satisfying my quest, I'll use template strings with printf() and vsprintf().
Code: (Demo)
<?php
$tr = <<<HTML
<tr style="color: %s;">%s
</tr>
HTML;
$tds = str_repeat("\n " . '<td>%s</td>', 4);
?>
<table>
<?php
foreach ($colors as $key => $color) {
printf(
$tr,
$color,
vsprintf(
$tds,
range($key, $key * 4, $key)
)
);
}
?>
</table>
Unrendered Output:
<table>
<tr style="color: #32CD32;">
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
</tr>
<tr style="color: #FF0000;">
<td>2</td>
<td>4</td>
<td>6</td>
<td>8</td>
</tr>
<tr style="color: #5E0087;">
<td>3</td>
<td>6</td>
<td>9</td>
<td>12</td>
</tr>
<tr style="color: #FFA500;">
<td>4</td>
<td>8</td>
<td>12</td>
<td>16</td>
</tr>
<tr style="color: #00008B;">
<td>5</td>
<td>10</td>
<td>15</td>
<td>20</td>
</tr>
</table>
Using pure CSS is the more professional technique for styling. Once you move the css to an external stylesheet, your php script will be very short and easy to manage.
Code with the same output: (Demo)
<style>
table {
border-collapse: collapse;
width: 1%;
}
tr:nth-child(1) { color: #32CD32; }
tr:nth-child(2) { color: #FF0000; }
tr:nth-child(3) { color: #5E0087; }
tr:nth-child(4) { color: #FFA500; }
tr:nth-child(5) { color: #00008B; }
td {
border: solid 1px black;
padding: 8px;
}
</style>
<?php
$tr = <<<HTML
<tr>
<td>%s</td>
<td>%s</td>
<td>%s</td>
<td>%s</td>
</tr>
HTML;
?>
<table>
<?php
for ($i = 1; $i <= 5; ++$i) {
vprintf(
$tr,
range($i, $i * 4, $i)
);
}
?>
</table>
I have a problem in inserting table from my database to div.
html code:
<div class="content">
<?php
$query = "SELECT name, surname FROM players";
$response = #mysqli_query($dbc, $query);
if($response) {
echo' <table align="left"
cellspacing="5" cellpadding="8" >
<tr><td align="left"><b>First Name</b></td>
<td align="left"><b>Last Name</b></td></tr>';
while($row = mysqli_fetch_array($response)) {
echo '<tr><td align="left">' .
$row['imie'] . '</td><td align="left">' .
$row['nazwisko'] . '</td><td align="left">';
echo '</tr>';
}
echo '</table>';
} else {
echo "Couldn't issue database query";
echo mysqli_error($dbc);
}
mysqli_close($dbc);
?>
</div>
css code:
.content {
width: 1000px;
margin-left: auto;
margin-right: auto;
background-color: #ffffff;
color: #000000;
border-bottom: 14px solid #333333;}
Is there a way to insert this table to this div? Because when I'm loading this, the table is under my div'content'. The table should be in blank field 'a'.
Screenshot
Correctly indenting your code would have allowed you o spot the error relatively easily - there is an open td element. Either remove the last td from the echo statement in the loop or add additional td pair to first row in table so that they balance ( unless you use colspan attributes )
<style>
.content table tr td{ align:left;padding:5px;color:black;background:white; }
</style>
<div class='content'>
<?php
$sql = 'select `name`, `surname` from `players`';
$response = mysqli_query( $dbc, $sql );
if( $response ) {
echo "
<table align='left' cellspacing='5' cellpadding='8' >
<tr>
<td><b>First Name</b></td>
<td><b>Last Name</b></td>
</tr>";
while( $row = mysqli_fetch_array( $response ) ) {
echo "
<tr>
<td>{$row['imie']}</td>
<td>{$row['nazwisko']}</td>
</tr>";
}
echo "
</table>";
} else {
printf( 'Couldn\'t issue database query: %s', mysqli_error( $dbc ) );
}
mysqli_close( $dbc );
?>
</div>
There is an open <td> tag in your code you should close it before closing the <tr>
I am creating an Excel download code, in which I am merging the TH cells and looping through TR to put data under specific merged TH.
But all of data is reflecting on first TH row. Below is code:
$K=0;
while($ROW = $RESULT->fetch_assoc() )
{
if($ROW['type'] == $_GET['separate_id'])
{
$DATE[] = $ROW['end_time'];
$meta_values[] = $ROW['meta_values'];
$body = '
<table style="border:1px solid #000; border-collapse:collapse;">
<thead style="border:1px solid #000; padding:8px;width:150px; height:25px;font-size:15px">
';
foreach($DATE as $DATES)
{
$DATESVIEW = explode('T',$DATES);
$body .=' <th colspan="2">'.$DATESVIEW[0].'</th> ';
}
$body .= '
</thead>
';
foreach($meta_values as $VALS)
{
$META_VALS = explode(' | ',$VALS);
foreach($META_VALS as $VALUEs)
{
$REs = explode(' - ', $VALUEs);
$body .= '
<tbody>
<tr style="border:1px solid #000; padding:8px;width:150px; height:25px;font- size:15px">
<td style="border:1px solid #000; padding:8px; width:150px; height:25px;font-size:15px">'.$REs[0].'</td>
<td style="border:1px solid #000; padding:8px; width:150px; height:25px;font-size:15px">'.$REs[1].'</td>
</tr>
</tbody>
';
}
}
}
$K++;
}
$body .= '
</table>
';
I have the following code that dynamically loads items in an invoice. I am looking for a way to adds excess items to a new page, and so on. I would like to limit the # of items on a page to a set amount, say 15 items. Is there a way to do this in php? The code below is within a document that uses dompdf to appear in pages form
foreach ( $invoice['InvoiceDetail'] as $key=>$item){
$html .= '<tr style="border-bottom: 1px solid #ccc; line-height: 15px;">';
$itemNo = isset($item['product_id']) ? $item['product_id'] : '';
$itemName = isset($item['productName']) ? $item['productName']: '';
$price = isset($item['price']) ? invoiceNumFormat($item['price']): '';
$quantity = isset($item['quantity']) ? $item['quantity'] : '';
$total = invoiceNumFormat( $item['price']*$item['quantity']);
$html .= '<td style="text-align: left"><h5>'.$itemNo.'</h5></td>';
$html .= '<td style="text-align: left">'.$itemName.'</td>';
$html .= '<td style="text-align: left">'.$price.'</td>';
$html .= '<td style="text-align: left" width="10px">'.$quantity.'</td>';
$html .= '<td style="text-align: right">'.$total.'</td>';
$html .= '</tr>';
}
For your particular situation you could just indicate to dompdf to break the page, something along the lines of:
$itemCount = 0;
foreach ( $invoice['InvoiceDetail'] as $key=>$item){
$itemCount++;
$html .= '<tr style="border-bottom: 1px solid #ccc; line-height: 15px;">';
/* snip */
if ($itemCount % 20 == 0) {
$html .= '<tr><td><div style="page-break-before: always;"></div></td></tr>';
}
$html .= '<td style="text-align: left"><h5>'.$itemNo.'</h5></td>';
$html .= '<td style="text-align: left">'.$itemName.'</td>';
$html .= '<td style="text-align: left">'.$price.'</td>';
$html .= '<td style="text-align: left" width="10px">'.$quantity.'</td>';
$html .= '<td style="text-align: right">'.$total.'</td>';
$html .= '</tr>';
}
Dompdf does not yet recognize page break styling on table rows/cells. Otherwise it would make more sense to place the styling there.
Does this help?
<?php
$per_page = 20;
if ( $pagenum < 2 || !$pagenum ) {
$limit_start = 0;
} else {
$limit_start = (( $pagenum -1 ) * $per_page);
}
$sql = "select foo, bar, baz from table where $conditions limit $limit_start, $per_page";
$db->query( $sql ); //or whatever your method is
// while statement to get data into $invoice array
//foreach statement to display it
//pagination links
I'm using HTML tables to display the name of a user, quiz id, and score.
And this is my code.
<?php
echo '<style>
table, th, td {
border: 1px solid black;
border-collapse: collapse;
}
th, td {
padding: 5px;
}
</style>';
$data = array();
$userid = 1;
$data[$userid] = array();
$name = 'Davy Jones';
$data[$userid]['name'] = $name;
$quiz = array(
'Qz1' => array(
'easy' => 1,
'normal' => 2,
'hard' => 3,
),
'Qz2' => array(
'easy' => 4,
'normal' => 5,
'hard' => 6,
),
);
$data[$userid]['quizzes'] = $quiz;
echo '<table style="width: 40%">';
echo '<tr>
<td>Name</td>
<td>Easy</td>
<td>Normal</td>
<td>Hard</td>
</tr>
<tr>
<td></td>
<td>Score</td>
<td>Score</td>
<td>Score</td>
</tr>';
foreach ($data as $key => $value) {
$quizzes = $value["quizzes"];
echo $value['name'].'<br>';
foreach ($quizzes as $key => $value2) {
echo $key.' '.$value2['easy'].'<br>';
echo $key.' '.$value2['normal'].'<br>';
echo $key.' '.$value2['hard'].'<br>';
}
}
echo '</table>';
For now I have this type of display.
I don't know how to manipulate the table and get this type of result.
Name Easy Normal Hard
Score Score Score
Qz1 Qz2 Qz1 Qz2 Qz1 Qz2
Davy Jones 1 4 2 5 3 6
Any ideas would be most appreciated.
You could use colspan for the table headings to span them across two columns for the information below them and then echo the appropriate variables and information in the cells:
http://jsfiddle.net/omzc6211/
Try to modify your code this way:
<?php
echo '
<style>
table, th, td {
border: 1px solid black;
border-collapse: collapse;
}
th, td {
padding: 5px;
}
</style>';
$data = array();
$userid = 1;
$data[$userid] = array();
$name = 'Davy Jones';
$data[$userid]['name'] = $name;
$quiz = array(
'Qz1' => array(
'easy' => 1,
'normal' => 2,
'hard' => 3,
),
'Qz2' => array(
'easy' => 4,
'normal' => 5,
'hard' => 6,
),
);
$data[$userid]['quizzes'] = $quiz;
echo '<table style="width: 40%">';
$quizTypes = array(
'easy',
'normal',
'hard'
);
$colspan = count($quiz);
echo '
<tr>
<td>Name</td>
<td colspan=' . $colspan . '>Easy</td>
<td colspan=' . $colspan . '>Normal</td>
<td colspan=' . $colspan . '>Hard</td>
</tr>
<tr>
<td></td>
<td colspan=' . $colspan . '>Score</td>
<td colspan=' . $colspan . '>Score</td>
<td colspan=' . $colspan . '>Score</td>
</tr>
';
foreach ($data as $user)
{
echo '<tr>';
echo '<td>' . $user['name'] . '</td>';
foreach ($quizTypes as $quizType)
{
foreach ($user["quizzes"] as $quizData)
{
echo '<td>' . (array_key_exists($quizType, $quizData) ? $quizData[$quizType] : '-') . '</td>';
}
}
echo '</tr>';
}
echo '</table>';
As suggested in the accepted answer you should use colspan, but here's the code for your very case:
<?php
echo '<style>
table, th, td {
border: 1px solid black;
border-collapse: collapse;
}
th, td {
padding: 5px;
}
</style>';
$data = array();
$userid = 1;
$data[$userid] = array();
$name = 'Davy Jones';
$data[$userid]['name'] = $name;
$quiz = array(
'Qz1' => array(
'easy' => 1,
'normal' => 2,
'hard' => 3,
),
'Qz2' => array(
'easy' => 4,
'normal' => 5,
'hard' => 6,
),
);
$data[$userid]['quizzes'] = $quiz;
echo '<table style="width: 40%">';
echo '<tr>
<td>Name</td>
<td colspan="2">Easy</td>
<td colspan="2">Normal</td>
<td colspan="2">Hard</td>
</tr>
<tr>
<td></td>
<td colspan="2">SCORES</td>
<td colspan="2">SCORES</td>
<td colspan="2">SCORES</td>
</tr>';
foreach ($data as $key => $value) {
$quizzes = $value["quizzes"];
$keys = "";
$easy = "";
$normal = "";
$hard = "";
foreach ($quizzes as $key => $value2) {
$keys .= '<td>'.$key.'</td>';
$easy .= '<td>'.$value2['easy'].'</td>';
$normal .= '<td>'.$value2['normal'].'</td>';
$hard .= '<td>'.$value2['hard'].'</td>';
}
echo '<tr><td></td>' . $keys . $keys . $keys . '</tr>';
echo '<tr><td>'.$value['name'].'</td>' . $easy . $normal . $hard . '</tr></table>';
}
?>