I am trying to group my data with country and year together and display it in a table but it is currently only grouped by year and not country.
As below -
USA 2020
| Reise | Land | Reisedatnum | Dauer | Reise |
| ------- | ------ | ------------- | ------- | ------- |
|12324 | Ak | 23-10-22 | AF |intensive|
USA 2020
|Reise |Land |Reisedatnum |Dauer |Reise|
|-|-|-|-|-|
|12323 |AG |3-10-22 |AF| intensive|
But it should be shown in one table only as Country and year are the same, currently is showing in a different table. I also grouped by keyregion
In database
keyregion = countryname
Year = $count=$row->jahr;
MySQL Query
function starttable($year,$country)
{
;
?>
<table class="termine" >
<caption class="date"><b><?php echo $country;?> <?php echo $year; ?> </b></caption>
<thead>
<tr>
<th scope="col" class="reisenr">Reise Nr.</th>
<th scope="col" class="land">Land</th>
<th scope="col" class="datum">Reisedatum</th>
<th scope="col" class="dauer">Dauer</th>
<th scope="col" class="reise">Reise</th>
<th scope="col" class="preis">Reisepreis</th>
</tr>
</thead>
<tbody>
<?
}
function closetable()
{
echo "
</tbody>
</table>
";
}
function ausgabe_einfach($zeile)
{
global $status;
$anfang = htmlentities($zeile->beginn_f,ENT_COMPAT,'UTF-8',0);
$ende = htmlentities($zeile->ende_f ,ENT_COMPAT,'UTF-8',0);
$commen = ($zeile->comment_de) ? "<div class=\"comment\">". nl2br(htmlentities($zeile->comment_de,ENT_COMPAT,'UTF-8',0)) ."</div>" : "";
?>
<tr>
<td><?php echo $zeile->reisenr ?></td>
<td><?php echo $zeile->keycountry .''.'<br>' . $zeile->Shortlink . ''?></td>
<td class="commdate"><?php echo $anfang ?> – <?php echo $ende ?></td>
<td><?php echo $zeile->tage+1 ?> T</td>
<td><?php echo $zeile->tourname ?></td>
<td><?php echo ($zeile->price) ? $zeile->price." Euro" : "-" ?> </td>
</tr>
<?
}
// Datenbankverbindung
$connection = #mysqli_connect("localhost","username","password","DB");
mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);
if ($connection)
{
mysqli_set_charset($connection, "UTF8");
mysqli_query($connection, "SET lc_time_names = 'de_DE'");
$keywords = "Afrika";
$zeig = 1;
if ($keysuffix == "")
$where = "WHERE keyregion LIKE \"".$keywords."\" AND zeig='$zeig'" ;
else
$where = "WHERE ( keyregion LIKE \"".$keywords."\" OR keycountry LIKE \"".$keywords.$keysuffix."\" )";
$abfrage = "SELECT reisenr,beginn,ende,airline,status,price,keywords,keyregion,Shortlink,keycountry,tourname, YEAR(beginn) AS jahr, MONTH(beginn) AS month, DATE_FORMAT(beginn,\"%a, %e. %b\") AS beginn_f,DATE_FORMAT(ende,\"%a, %e. %b %Y\") AS ende_f,comment_de, DATEDIFF(ende,beginn) as tage FROM $tabelle $where ORDER BY jahr, keyregion";
$ergebnis = mysqli_query($connection, $abfrage);
$opentab = false; // Tabelle offen
$p_month=0;
// Aktueller Jahresdurchlauf
while($row = mysqli_fetch_object($ergebnis))
{
if ($row->month != $p_month)
{
$p_month=$row->month;
$datee= htmlentities($row->beginn,ENT_COMPAT,'UTF-8',0);
$count=$row->jahr;
$country= $row->keyregion;
$bigin =htmlentities($row->beginn,ENT_COMPAT,'UTF-8',0);
if ($opentab)
closetable();
starttable($count,$country);
$opentab = true;
}
ausgabe_einfach($row);
}
if ($opentab)
closetable();
}
else
{ ?>
Daten können nicht geladen werden.
<?
}
Related
Hi I have data in my MYSQL which I am trying to sort by Months and Year together and display it in new HTML table every time sort by Year and months.
trying to do like this -
January 2021
Reise Nr. Reisedatum Dauer Flug Reis
2122330 Di, 1. jan – Do, 24. jan 2022 23 T AF Mali Intensiv
February 2021
Reise Nr. Reisedatum Dauer Flug Reis
2122330 Di, 1. Feb – Do, 24. Feb 2022 23 T AF Mali Intensiv
(Months wise data)
But HTML table is sorted by year only not months. see below the output.
But I am trying to make it like this January 2021 data is different table and OKT = October 2021 data in new table like below image
Here is my PHP CODE -
<?php
$tabelle="Termine_afrika";
$keysuffix="";
$status = array('freie Plätze','ausgebucht','nicht mehr buchbar','Restplätze','auf Anfrage','entfällt');
function starttable($year,$month)
{
?>
<table class="termine" >
<caption><?php echo date("F",strtotime($month)); ?> <?php echo $year ?></caption>
<thead>
<tr>
<th scope="col" class="reisenr">Reise Nr.</th>
<th scope="col" class="datum">Reisedatum</th>
<th scope="col" class="dauer">Dauer</th>
<th scope="col" class="flug">Flug</th>
<th scope="col" class="reise">Reise</th>
<th scope="col" class="preis">Reisepreis</th>
<th scope="col" class="status">Status</th>
</tr>
</thead>
<tbody>
<?
}
function closetable()
{
echo "
</tbody>
</table>
";
}
function ausgabe_einfach($zeile)
{
global $status;
$anfang = htmlentities($zeile->beginn_f,ENT_COMPAT,'UTF-8',0);
$ende = htmlentities($zeile->ende_f ,ENT_COMPAT,'UTF-8',0);
$commen = ($zeile->comment_de) ? "<div class=\"comment\">". nl2br(htmlentities($zeile->comment_de,ENT_COMPAT,'UTF-8',0)) ."</div>" : "";
?>
<tr>
<td><?php echo $zeile->reisenr ?></td>
<td><?php echo $anfang ?> – <?php echo $ende . $commen ?></td>
<td><?php echo $zeile->tage ?> T</td>
<td><?php echo $zeile->airline ?></td>
<td><?php echo $zeile->tourname ?></td>
<td><?php echo ($zeile->price) ? $zeile->price." Euro" : "-" ?> </td>
<td><?php echo $status[$zeile->status] ?></td>
</tr>
<?
}
$connection = #mysqli_connect("localhost","user","pass","DB");
mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);
if ($connection)
{
mysqli_set_charset($connection, "UTF8");
mysqli_query($connection, "SET lc_time_names = 'de_DE'");
$keywords = "mali";
$zeig = 1;
if ($keysuffix == "")
$where = "WHERE keycountry LIKE \"".$keywords."\" AND zeig='$zeig'" ;
else
$where = "WHERE ( keycountry LIKE \"".$keywords."\" OR keycountry LIKE \"".$keywords.$keysuffix."\" )";
$abfrage = "SELECT reisenr,beginn,ende,airline,status,price,keywords,keycountry,tourname, YEAR(beginn) AS jahr, DATE_FORMAT(beginn,\"%a, %e. %b\") AS beginn_f,DATE_FORMAT(ende,\"%a, %e. %b %Y\") AS ende_f,comment_de, DATEDIFF(ende,beginn) as tage FROM $tabelle $where ORDER BY jahr, beginn";
$ergebnis = mysqli_query($connection, $abfrage);
$opentab = false; // Tabelle offen
$count=0; // Aktueller Jahresdurchlauf
while($row = mysqli_fetch_object($ergebnis))
{
if (intval($row->jahr) > $count)
{
$count=$row->jahr;
$bigin = $row->beginn;
if ($opentab)
closetable();
starttable($count,$bigin);
$opentab = true;
}
ausgabe_einfach($row);
}
if ($opentab)
closetable();
}
else
{ ?>
Daten können nicht geladen werden.
<?
}
?>
do comparison between months not years and get month from DB also break line and add new line only when month change
Update query
$abfrage = "SELECT reisenr,beginn,ende,airline,status,price,keywords,keycountry,tourname, YEAR(beginn) AS jahr, MONTH(beginn) AS month, DATE_FORMAT(beginn,\"%a, %e. %b\") AS beginn_f,DATE_FORMAT(ende,\"%a, %e. %b %Y\") AS ende_f,comment_de, DATEDIFF(ende,beginn) as tage FROM $tabelle $where ORDER BY jahr, MONTH(beginn)";
update code
$p_month=0;
// Aktueller Jahresdurchlauf
while($row = mysqli_fetch_object($ergebnis))
{
if ($row->month != $p_month)
{
$p_month=$row->month;
$count=$row->jahr;
$bigin = $row->beginn;
if ($opentab)
closetable();
starttable($count,$bigin);
$opentab = true;
}
ausgabe_einfach($row);
}
I have a table and each , I want to select a data from the same table in my database.
For example, first <td> is first name, then the second <td> is phone number.
I got the command, but only the first command is showing output.
This is my php codes to open and connect to the database :
<?php
include("./inc/db_connect.php");
$conn = OpenCon();
?>
This is the php codes for the table including <th> and <td> :
<div class="layer55">
<h3>
<table class="flat-table">
<tbody>
<tr>
<th>
<?php
$sql = "SELECT * FROM sharp_emp WHERE employee_id = 'AA170336'";
if ($result = $conn->query($sql)) {
if ($result->num_rows > 0) {
echo "Name";
}
}
?>
</th>
<th>
<?php
$sql = "SELECT * FROM sharp_emp WHERE employee_id = 'AA170336'";
if ($result = $conn->query($sql)) {
if ($result->num_rows > 0) {
echo "Phone Number";
}
}
?>
</th>
</tr>
<tr>
<td>
<?php
$sql = "SELECT first_name FROM sharp_emp WHERE employee_id = 'AA170336'";
while ($row = $result->fetch_array()) {
echo "" . $row['first_name'] . "";
}
?>
</td>
<td>
<?php
$sql = "SELECT phone FROM sharp_emp WHERE employee_id = 'AA170336'";
while ($row = $result->fetch_array()) {
echo "" . $row['phone'] . "";
}
?>
</td>
</tr>
</tbody>
</table>
</h3>
</div>
This is the php codes for db_connect.php :
<?php
function OpenCon()
{
$dbhost = "localhost";
$dbuser = // Hidden;
$dbpass = // Hidden;
$db = "sharp_db";
$conn = new mysqli($dbhost, $dbuser, $dbpass,$db) or die("Connect failed: %s\n". $conn -> error);
return $conn;
}
function CloseCon($conn)
{
$conn -> close();
}
?>
The expected output :
|----------|----------|
|Name |Phone Number|
|----------|----------|
|John |179898765 |
The current output :
|----------|----------|
|Name |Phone Number|
|----------|----------|
|John |Null (empty) |
You are running the same query multiple times, overwriting the $result variable for no reason, having useless $sql for the later 2 fetch without using them, and fetching a single $result twice by mistake.
So there are multiple concept problem with your code. I think your current code is something equivalant to this:
<div class="layer55">
<h3>
<table class="flat-table">
<tbody>
<tr>
<?php
$sql = "SELECT * FROM sharp_emp WHERE employee_id = 'AA170336'";
if ($result = $conn->query($sql)) {
if ($result->num_rows > 0) {
?>
<th>Name</th>
<th>Phone Number</th>
<?php } else { ?>
<th></th>
<th></th>
<?php } ?>
<?php } ?>
</tr>
<tr>
<?php if ($row = $result->fetch_array()) { ?>
<td><?php echo "" . $row['first_name'] . ""; ?></td>
<td><?php echo "" . $row['phone'] . ""; ?></td>
<?php } else { ?>
<td></td>
<td></td>
<?php } ?>
</tr>
</tbody>
</table>
</h3>
</div>
But frankly, it makes no sense to me to print an empty table when there is no result. So what you need is probably something like this.
<?php
$sql = "SELECT * FROM sharp_emp WHERE employee_id = 'AA170336'";
if (
($result = $conn->query($sql))
&& ($result->num_rows > 0)
&& ($row = $result->fetch_array())
):
?>
<div class="layer55">
<h3>
<table class="flat-table">
<tbody>
<tr>
<th>Name</th>
<th>Phone Number</th>
</tr>
<tr>
<td><?php echo $row['first_name']; ?></td>
<td><?php echo $row['phone']; ?></td>
</tr>
</tbody>
</table>
</h3>
</div>
<?php endif; ?>
i am fetching data from db in datatable , but my while loop is only fetching first row results . i can guess that i am wrong somewhere but not exactly know where . find below the details
Tables :
user :
user_id | user_role_id | user_name | fname | lname | profile
:-----: | :----------: | :-------: | :---: | :---: | :-----:
1 | 2 | schin | sam | chin | t1.png
2 | 2 | mlouis | mark | louis| t2.png
teachers :
t_id | classes | subjects | pri_classes | primary_subjects | email
:-----: | :----------: | :-------: | :---------: | :--------------: | :-----:
1 | eight,nine | math,phy | nine | maths | 1#gmail.com
2 | two | science | two | science | 2#gmail.com
Php Query :
<?php
$sql3 = "select * from user where user_role_id = 2";
$result3 = $dbh->query($sql3);
$row3 = mysqli_fetch_assoc($result3);
$user_id = $row3['user_id'];
$sql4 = "select * from teachers where t_id = '$user_id'";
$result4 = $dbh->query($sql4);
?>
Table head :
<table id="datatable-table" class="table table-striped table-hover">
<thead>
<tr>
<th>S.no</th>
<th class="no-sort hidden-sm-down">Image</th>
<th >Name</th>
<th >User Name</th>
<th >Classes Handled</th>
<th >Subjects Handled</th>
<th >Primary Class</th>
<th >Primary Subjects</th>
<th >Email</th>
</tr>
</thead>
<tbody>
While loop :
<?php
while(($row4 = mysqli_fetch_assoc($result4))&&($row3)){
?>
<tr align="center">
<td>
<?php
$i = 1;
echo $i;
$i++;
?>
</td>
<td>
<span >
<img src="../img/<?php echo $row3['profile'];?>" style="width:40px; height:40px;">
</span>
</td>
<td>
<span class="fw-semi-bold">
<?php echo $row3['fname'].' '.$row3['lname']; ?>
</span>
</td>
<td>
<span class="fw-semi-bold">
<?php echo $row3['user_name']; ?>
</span>
</td>
<td><span class="fw-semi-bold">
<?php
$classes=explode(',', $row4['classes']);
$prefix = '';
foreach($classes as $cout)
{
echo $prefix . '' . wordsToNumber($cout);
$prefix = ', ';
}
?>
</span>
</td>
<td><span class="fw-semi-bold">
<?php
$subjects=explode(',', $row4['subjects']);
$prefix = '';
foreach($subjects as $sout) {
echo $prefix . '' . str_replace('\' ', '\'', ucwords(str_replace('\'', '\' ', strtolower($sout))));
$prefix = ', ';
}
?>
</span>
</td>
<td>
<span class="fw-semi-bold">
<?php
echo wordsToNumber($row4['pri_classes']);
?>
</span></td>
<td><span class="fw-semi-bold">
<?php
echo str_replace('\' ', '\'', ucwords(str_replace('\'', '\' ', strtolower($row4['primary_subjects']))));
?>
</span></td>
<td><span class="fw-semi-bold"><?php echo wordwrap($row4['email'],10, "<br>\n"); ?></span></td>
</tr>
<?php
}
?>
</tbody>
</table>
For wordsToNumber i use this function
Your first query is only retrieving a single user. You need nested loops.
while ($row3 = mysqli_fetch_assoc($result3)) {
$user_id = $row3['user_id'];
$result4 = $dbh->query("select * from teachers where t_id = '$user_id'");
while($row4 = mysqli_fetch_assoc($result4)){
// display etc
}
}
You may want to consider some joins in MySQL to avoid so many queries http://dev.mysql.com/doc/refman/5.7/en/join.html
How can I read the latest number from the following code
<table width="100" border="1" >
<tr align="center" bgcolor="#999999" >
<td >NO</td>
<td >Name</td>
<td >PBSID</td>
</tr>
$query ="select * from stock ";
$hasil = mysql_query($query);
$no=0;
while ($row = mysql_fetch_array($hasil))
{
$no++;
if($x != $row[pbsid] )
{
$no=1;
echo "<tr bgcolor=#CCCCCC>
<td colspan=4 ><b> GROUP $row[pbsid]</b></td>
</tr>";
}
$mo=count($no);
echo "<tr><td>$no </td><td> $row[bnama]</td><td>$row[pbsid] </td></tr>";
$x = $row["pbsid"];
}
The result:
===========
NO | NAME | GROUP
---------------------------------------
===========
GROUP 1
---------------------------------------
===========
1 | A | 1
2 | B | 1
3 | C | 1
4 | D | 1
---------------------------------------
===========
GROUP 2
---------------------------------------
===========
1 | A | 2
2 | B | 2
3 | C | 2
I want to show the latest GROUP number, Group 1=4 and Group 2=3, can anyone help me with this?
Try this query:
SELECT s.*, c.count
FROM stock AS s
LEFT JOIN ( SELECT pbsid, COUNT(1) AS `count` FROM stock GROUP BY pbsid ) AS c
ON s.pbsid = c.pbsid
Now you will have the count for each group, which is what it seems you really want.
If you'd prefer to do all the work in PHP for some reason, you could do it like this:
<table width="100" border="1" >
<tr align="center" bgcolor="#999999" >
<td >NO</td>
<td >Name</td>
<td >PBSID</td>
</tr>
$query ="select * from stock ";
$hasil = mysql_query($query);
$no=0;
$counts = array(); // make an array of counts for each group, keyed by pbsid
$rows = array(); // put all the data from SQL into an array
while ($row = mysql_fetch_array($hasil))
{
$rows[] = $row;
if (!isset($counts[$row[pbsid]]))
{
$counts[$row[pbsid]] = 0; // initialize it to 0
}
$counts[$row[pbsid]]++; // increment for each occurrence of a pbsid
}
foreach ($rows as $row)
{
$no++;
if($x != $row[pbsid] )
{
$no=1;
echo "<tr bgcolor=#CCCCCC>
<td colspan=4 ><b> GROUP $row[pbsid]</b> Count = " . $counts[$row[pbsid]] . " </td>
</tr>";
}
$mo=count($no);
echo "<tr><td>$no </td><td> $row[bnama]</td><td>$row[pbsid] </td></tr>";
$x = $row["pbsid"];
}
Although, I think it's much simpler to just have this information calculated in your query.
This would work
$query ="select * from stock ";
$hasil = mysql_query($query);
$no=0;
$latest = array();
while ($row = mysql_fetch_array($hasil))
{
$no++;
if($x != $row[pbsid] ){
$no=1;
echo "<tr bgcolor=#CCCCCC>
<td colspan=4 ><b> GROUP $row[pbsid]</b></td>
</tr>";
}
$mo=count($no);
echo "<tr><td>$no </td><td> $row[bnama]</td><td>$row[pbsid] </td></tr>";
$x = $row["pbsid"];
$key = 'Group'.$row['pbsid'];
$latest[$key] = $no;
}
print_r($latest);
<table width="100" border="1" >
<tr align="center" bgcolor="#999999" >
<td >NO</td>
<td >Name</td>
<td >PBSID</td>
</tr>
$last_no = array();
$query ="select * from stock ";
$hasil = mysql_query($query);
$no=0;
while ($row = mysql_fetch_array($hasil))
{
$no++;
if($x != $row[pbsid] ){
$no=1;
echo "<tr bgcolor=#CCCCCC>
<td colspan=4 ><b> GROUP $row[pbsid]</b></td>
</tr>";
}
$mo=count($no);
echo "<tr><td>$no </td><td> $row[bnama]</td><td>$row[pbsid] </td></tr>";
$x = $row["pbsid"];
$last_no[] = $no;
}
print_r($last_no);
Change your query $query ="select MAX(no),bnama, pbsid from yourtablename GROUP BY pbsid ";
I am wanting to make the data to show in 2 columns instead of one here is the code I currently use to show the data in 1 column:
<?php
include("config.php");
include("opendb.php");
$get_cats = mysql_query("SELECT * FROM `categories` ORDER BY `displayorder`") or die(mysql_error());
$get_info = mysql_query("SELECT * FROM `systeminfo`") or die(mysql_error());
$info = mysql_fetch_array($get_info);
while($cats = mysql_fetch_array($get_cats)) {
$get_rares = mysql_query("SELECT * FROM `rares` WHERE `catid`='".$cats['id']."'") or die(mysql_error());
echo("<h2>".$cats['name']."</h2><br>
<table width=\"100%\" border=\"0\">
<tr>
<td width=\"20%\" style=\"text-align:center\"><b>Image</b></td>
<td width=\"40%\" style=\"text-align:left\"><b>Item Name</b></td>
<td width=\"10%\" style=\"text-align:center\"><b>Value</b></td>
<td width=\"30%\" style=\"text-align:center\"><b>Last Updated</b></td>
</tr>
");
$color1 = $info[stripe1];
$color2 = $info[stripe2];
$row_count = 0;
while($rare = mysql_fetch_array($get_rares)) {
$row_color = ($row_count % 2) ? $color1 : $color2;
?>
<tr>
<td width="5%" style="text-align:center;background-color:#<?php echo $row_color; ?>"><img alt="" src="<?php echo("".$info[imagepath]."".$rare['image'].""); ?>"></td>
<td width="20%" style="text-align:left;background-color:#<?php echo $row_color; ?>"><?php echo $rare['name']; ?></td>
<td width="20%" style="text-align:center;background-color:#<?php echo $row_color; ?>"><?php echo $rare['value']; ?> Credits</td>
<td width="10%" style="text-align:center;background-color:#<?php echo $row_color; ?>"><?php echo $rare['lastedited']; ?></td>
</tr>
<?php
$row_count++;
}
echo("</table><br>
");
}
?>
Currently is shows as:
1
_________
2
_________
3
_________
4
_________
5
_________
6
_________
I would like it to show like this:
1 | 2
_________ | _________
3 | 4
_________ | _________
5 | 6
_________ | _________
This really doesn't have anything to do with MySQL at all. MySQL's just the source of the data. You'd want something like this:
$record = 0;
while($rare = mysql_fetch_array($get_rares)) {
if ($record % 2 == 0) {
echo "<tr>"; // if on an 'even' record, start a new row
}
echo "<td>{$rare['something']}</td>";
$record++;
if ($record % 2 == 0) {
echo "</tr>"; // close the row if we're on an even record
}
}
For what it's worth, I encorporated MarcB's code into your original code. You were already doing the mod with your row count. I think you want something like this:
<?php
include("config.php");
include("opendb.php");
$get_cats = mysql_query("SELECT * FROM `categories` ORDER BY `displayorder`") or die(mysql_error());
$get_info = mysql_query("SELECT * FROM `systeminfo`") or die(mysql_error());
$info = mysql_fetch_array($get_info);
while($cats = mysql_fetch_array($get_cats)) {
$get_rares = mysql_query("SELECT * FROM `rares` WHERE `catid`='".$cats['id']."'") or die(mysql_error());
echo("<h2>".$cats['name']."</h2><br>
<table width=\"100%\" border=\"0\">
<tr>
<td width=\"20%\" style=\"text-align:center\"><b>Image</b></td>
<td width=\"40%\" style=\"text-align:left\"><b>Item Name</b></td>
<td width=\"10%\" style=\"text-align:center\"><b>Value</b></td>
<td width=\"30%\" style=\"text-align:center\"><b>Last Updated</b></td>
<td width=\"20%\" style=\"text-align:center\"><b>Image2</b></td>
<td width=\"40%\" style=\"text-align:left\"><b>Item Name2</b></td>
<td width=\"10%\" style=\"text-align:center\"><b>Value2</b></td>
<td width=\"30%\" style=\"text-align:center\"><b>Last Updated2</b></td>
</tr>
");
$color1 = $info[stripe1];
$color2 = $info[stripe2];
$row_count = 0;
while($rare = mysql_fetch_array($get_rares)) {
$row_color = ($row_count % 2) ? $color1 : $color2;
if ($row_count % 2 == 0) {
echo "<tr>"; // if on an 'even' record, start a new row
}
echo "<td width='5%' style='text-align:center;background-color:#$row_color;'><img alt='' src='{$info[imagepath]}{$rare['image']}'></td>
<td width='20%' style='text-align:left;background-color:#$row_color;'>{$rare['name']}</td>
<td width='20%' style='text-align:center;background-color:#$row_color;'>{$rare['value']} Credits</td>
<td width='10%' style='text-align:center;background-color:#$row_color;'>{$rare['lastedited']}</td>";
if ($row_count % 2 == 0) {
echo "</tr>"; // close the row if we're on an even record
}
$row_count++;
}
echo "</table><br/>";
}
?>