-2
<div id="report-tbl-holder">
        <table id="report-tbl" class="table table-stripped table-bordered">
            <thead>
                <tr>
                    <th>#</th>
                    <th>Date/Time</th>
                    <th>Person's Code/Name</th>
                    <th>Establishment's/Barangay Code/Name</th>
                    <th>Temperature</th>
                </tr>
            </thead>
            <tbody>
                <?php
                $i = 1;
                $where = ($eid > 0 && is_numeric($eid)) ? " and e.id = {$eid} " : "";
                $tracks = $conn->query("SELECT t.*,Concat(p.firstname,' ',p.middlename,' ',p.lastname)as pname,p.code as pcode, e.name as ename,e.code as ecode from tracks t inner join people p on p.id=t.person_id inner join establishment e on. e.id = t.establishment_id where date_format(t.date_added,'%Y-%m-%d') BETWEEN '{$date_start}' and '{$date_end}' $where order by date(t.date_added) asc");
                while($row=$tracks->fetch_assoc()):

                ?>
                <tr>
                    <td class="text-center"><?php echo $i++; ?></td>
                    <td><?php echo date("M d, Y h:i A",strtotime($row['date_added'])) ?></td>
                    <td><?php echo $row['pcode'] . ' - ' . (ucwords($row['pname'])) ?></td>
                    <td><?php echo $row['ecode'] . ' - ' . (ucwords($row['ename'])) ?></td>

                </tr>
                <?php endwhile; ?>
            </tbody>
        </table>

I created a row in my database named "temperature" and wanted to include it in a table on the webpage I have created but I don't know how to call the contents of the newly added row (temperature) to display. It did add a new row because I added "Temperature" in the table header but I don't know how to properly call the values for temperature from the database.

enter image description here

enter image description here

Dharman
  • 30,962
  • 25
  • 85
  • 135
  • **Warning:** You are wide open to [SQL Injections](https://php.net/manual/en/security.database.sql-injection.php) and should use parameterized **prepared statements** instead of manually building your queries. They are provided by [PDO](https://php.net/manual/pdo.prepared-statements.php) or by [MySQLi](https://php.net/manual/mysqli.quickstart.prepared-statements.php). Never trust any kind of input! Even when your queries are executed only by trusted users, [you are still in risk of corrupting your data](http://bobby-tables.com/). [Escaping is not enough!](https://stackoverflow.com/q/5741187) – Dharman Aug 07 '21 at 10:35

2 Answers2

0

I think that there's a confusion... Here "Temperature" is not a row, but a column.

You can try to add the following code line inside your loop :

<td><?php echo $row['body_temp'] ?></td>
moDevsome
  • 189
  • 2
  • 16
0

You can simply get the data from database in same manner as you are getting in last table columns . you have to give just newly added column name into $rows array.

<tr>
     <td class="text-center"><?php echo $i++; ?></td>
     <td><?php echo date("M d, Y h:i A",strtotime($row['date_added'])) ?></td>
     <td><?php echo $row['pcode'] . ' - ' . (ucwords($row['pname'])) ?></td>
     <td><?php echo $row['ecode'] . ' - ' . (ucwords($row['ename'])) ?></td>
     <td><?=$row['body_temp'] ?></td>
</tr>