How to Not display empty rows? - php

My question is:
If you look at where it would display "
<td>1ST<?php echo $first ?></td>
"
How do I ensure that if the row associate to variable '$first' or all the others if they are empty nothing shows. Also that the '1st' doesn't show?
Have tried various things I am stumped on this!
<h2><?php echo $show_title ?></h2>
<h4>Show Date: <span class="glyphicon glyphicon-time"> </span><?php echo $show_date ?></h4>
<hr>
</a>
<hr>
<?php
// SO UPDATE THE QUERY TO ONLY PULL THAT SHOW'S DOGS
$query = "SELECT * FROM result
WHERE first IS NOT NULL";
$result = mysqli_query($connection, $query) or trigger_error
("Query Failed! SQL: $query - Error: ". mysqli_error
($connection), E_USER_ERROR);
if ($result) {
while ($row = mysqli_fetch_assoc($result)) {
$dog_name = $row['dog_name'];
$placement = $row['placement'];
$class_name = $row['class_name'];
$entries = $row['entries'];
$absentee = $row['absentee'];
$entries = $row['entries'];
$first = $row['first'];
$second = $row['second'];
$third = $row['third'];
$RES = $row['RES'];
$VHC = $row['VHC'];
$DCC = $row['DCC'];
$RDCC = $row['RDCC'];
$BCC = $row['BCC'];
$RBCC = $row['RBCC'];
$BOB = $row['BOB'];
$BP = $row['BP'];
$BJ = $row['BJ'];
?>
<table class="table" border="0"></div>
<tr>
<td><strong><?php echo $class_name ?></strong> - <h6>Entries: <?php echo $entries ?> Absentees: <?php echo $absentee ?></h6></td>
<td></td>
</tr>
<tr>
<td>DCC</td>
<td><?php echo $DCC ?></td>
</tr>
<tr>
<td>RDCC</td>
<td><?php echo $RDCC ?></td>
</tr>
<tr>
<td>BCC</td>
<td><?php echo $BCC ?></td>
</tr>
<tr>
<td>RBCC</td>
<td><?php echo $RBCC ?></td>
</tr>
<tr>
<td>BOB</td>
<td><?php echo $BOB ?></td>
</tr>
<tr>
<td>BP</td>
<td><?php echo $BP ?></td>
</tr>
<tr>
<td>BJ</td>
<td><?php echo $BJ ?></td>
</tr>
<tr>
<td>1ST</td>
<td><?php echo $first ?></td>
</tr>
<tr>
<td>2ND</td>
<td><?php echo $second ?></td>
</tr>
<tr>
<td>3RD</td>
<td><?php echo $third ?></td>
</tr>
<tr>
<td>RES</td>
<td><?php echo $RES ?></td>
</tr>
<tr>
<td>VHC</td>
<td><?php echo $VHC ?></td>
</tr>
</table>

You're doing well, just apply a filtering function to each row you recieve:
// SO UPDATE THE QUERY TO ONLY PULL THAT SHOW'S DOGS
$query = "SELECT * FROM result
WHERE first IS NOT NULL";
$result = mysqli_query($connection, $query);
if (!$result) {
trigger_error("Query Failed! SQL: $query - Error: ". mysqli_error($connection), E_USER_ERROR);
} else {
// Fetch results into array
$data = mysqli_fetch_all($result, MYSQLI_ASSOC);
// If results array is not empty
if ($data) {
echo '<table class="table" border="0"></div>
<tr>
<td>
<strong><?php echo $class_name ?></strong> - <h6>Entries: <?php echo $entries ?> Absentees: <?php echo $absentee ?></h6>
</td>
<td></td>
</tr>';
// Now let's walk through every record
array_walk($data, function($dogRecord) {
// Here we apply array_filter to each dog record, so that empty values (i.e. those evaluating to false) are filtered out
$dogRecord = array_filter($dogRecord);
// Now loop throw $dogRecord to build table
$collation = [
'DCC' => 'DCC',
'RDCC' => 'RDCC',
'BCC' => 'BCC',
'RBCC' => 'RBCC',
'BOB' => 'BOB',
'BP' => 'BOB',
'BJ' => 'BOB',
'1ST' => 'first',
'2ND' => 'second',
'3RD' => 'third',
'RES' => 'RES',
'VHC' => 'RES'
];
foreach ($dogRecord as $property => $value) {
echo '<tr>
<td>'.$collation[$property].'</td>
<td>'.$value.'</td>
</tr>';
}
});
echo '</table>';
}
}
Note that instead of simple foreach loop I'm using array_walk function. This is because since you extract variables for each record, you want undeclared (i.e. unoccupied) varables every time.

What about this:
if(mysqli_num_rows($result) > 0){
while($row = mysqli_fetch_assoc($result)){
// Show the table-row
}
}

The following code will iterate through each row in the result (while loop) and each key => value within each row (foreach loop); it will then check if a value is not null or the key is not equal to 'first' (if statement) and echo the results in the table element. I'm not sure I fully understood your question but I hope this helps in some small way.
<table>
<?php
if($result){
while($row = mysqli_fetch_assoc($result))
foreach($row as $key => $value){
if($value != null && $key != 'first'){
echo '<tr>';
echo '<td>' . $key . '</td>';
echo '<td>' . $value . '</td>';
echo '</tr>';
}
}
}
?>
</table>

Related

php table add values if cell repeats

I have a wordpress loop retriving a table like this:
I want to check if the name repeats it self and if so do a sum of partial values to show the total.
On my screenshot the 1st and 3rd rows have the same "nome" so the global value should be 85, can any one tellme how to do this ?
my php :
<?php while( have_rows('wallet_repeater') ): the_row();
echo '<div class="promotoras_item_wallet"> ';
echo '<div class="promnames_wallet"> ';
// vars
$adicionados = get_sub_field('wallet_promotora');
foreach($adicionados as $post) :
$nome = simple_fields_values("pname1");
$im = simple_fields_values("ftotop");
$cp=$adicionados ;
$imatop = $im;
$data=get_sub_field('wallet_data');
$evento=get_sub_field('wallet_evento');
$obs=get_sub_field("wallet_obs");
$numeros_horas = get_sub_field("Wallet_n_horas");
$valor_horas = get_sub_field("wallet_valorh");
$evento = get_sub_field("wallet_evento");
$horarios = get_sub_field("wallet_horario");
$total_parcial = $valor_horas * $numeros_horas."€";
$ii = wp_get_attachment_image($imatop[0]);
?>
<table id="wallet_table1" width="900px" border="0" cellspacing="2" cellpadding="0">
<tbody>
<tr>
<tr onmouseover="this.style.backgroundColor='#ffff66';" onmouseout="this.style.backgroundColor='#d4e3e5';">
<td class="wallet_data_img" width="5"><div class="w_promotora_images"><?php echo wp_get_attachment_image($imatop[0]); ?></td>
<td class="wallet_data_data" width="20"><?php echo the_sub_field('wallet_data'); ?> </td>
<td class="wallet_data_nome" width="200"><?php echo $nome[0];$nomes[]=$nome[0];?></td>
<td class="wallet_data_evento" width="10"> <?php echo the_sub_field("wallet_evento"); ?></td>
<td class="wallet_data_horarios" width="10"><?php echo the_sub_field("wallet_horario"); ?></td>
<td class="wallet_data_obs" width="10"><?php echo the_sub_field("wallet_obs"); ?></td>
<td class="wallet_data_horas" width="10"><?php echo the_sub_field("Wallet_n_horas")."h"; ?></td>
<td class="wallet_data_valorh" width="5"><?php echo the_sub_field("wallet_valorh")."€"; ?></td>
<td class="wallet_data_props" width="5"><?php echo the_sub_field("wallet_props"); ?></td>
<td class="wallet_data_total" width="5">Parcial: <?php echo $total_parcial; ?> global:
</td> </tr></tbody></table>
<?php
Stuff the query data into an associative array and after that output it.
You can do it like that:
$qry = new WP_Query('post_type' => 'your_post_type', 'posts_per_page' => -1)
$arr = array();
while($qry->have_posts()) {
$qry->the_post()
$nam = //Get the name data;
$val = //Get the «global» data;
if($qry[$nam]) {
$qry[$nam]['global'] += $val;
}
else {
$qry[$nam] = array(
'foto' => //Photo data of the current post,
'name' => //Photo data of the current post,
//and so on
'global' => $val,
);
}
}
foreach($qry as $key => $data) {
//Output your table here
}

Editable Datatables PHP MySQL jQuery

I have a table which is fed dynamically from the database, this works as it should, I've then put the datatables functionality on the top which is working well, the sorting, search, the pagination is again working as it should.
I'm now looking at being able to edit a row and update the data back into the db and refresh the table.
My table structure
<table class="table table-striped table-hover table-bordered" id="tobebookedtable">
<thead>
<tr>
<th style="display:none;">PropID</th>
<th>ProjectNo</th>
<th>Householder</th>
<th>HouseNoName</th>
<th>Street Name</th>
<th>Postcode</th>
<th>Telephone</th>
<th>EPCPlanned</th>
<th>TAM</th>
</tr>
</thead>
<tbody>
<tr>
<?php
$planning = db::getInstance()->query('CALL sp_tobebooked()');
foreach ($planning->results() as $planning) {
?>
<td style="display:none;"><?php echo $planning->PropID; ?></td>
<td><?php echo $planning->ProjectNo; ?></td>
<td><?php echo $planning->Householder; ?></td>
<td><?php echo $planning->HouseNoName; ?></td>
<td><?php echo $planning->StreetName; ?></td>
<td><?php echo $planning->Postcode; ?></td>
<td><?php echo $planning->Telephone; ?></td>
<td><?php echo $planning->EPCPlanned; ?></td>
<td><?php echo $planning->TAM; ?></td>
</tr>
<?php }; ?>
</tbody>
</table>
The EPCPlanned is the only field I want to update.
This here is my code for the jQuery side, the edit ability works, I can click into a cell and edit the record.
<script type="text/javascript">
$(document).ready(function() {
$('#tobebookedtable').dataTable( {
//"bProcessing": true,
//"bServerSide": true,
//"bJQueryUI": true,
"bPaginate": true,
"bStateSave": true
} );
/* Init DataTables */
var oTable = $('#tobebookedtable').dataTable();
/* Apply the jEditable handlers to the table */
oTable.$('td').editable( 'tobebooked_edit.php', {
"callback": function( sValue, y ) {
var aPos = oTable.fnGetPosition( this );
oTable.fnUpdate( sValue, aPos[0], aPos[1] );
//window.location.reload();
},
"submitdata": function ( value, settings ) {
console.log(value);
console.log(settings);
return {
"row_id": this.parentNode.getAttribute('id'),
"column": oTable.fnGetPosition( this )[2]
};
},
"height": "26px",
"width": "100%"
} );
} );
</script>
this is the tobebooked_edit.php
<?php
require 'core/init.php';
$table="temp_tobebooked";
$rawdata = $_POST;
$query = "show columns from $table";
$result= mysql_query($query) or die(mysql_error());
$fields = array();
while ( $row = mysql_fetch_assoc($result) )
{
$fieldname = $row['Field'];
array_push($fields, $fieldname);
}
$id = $rawdata['row_id'];
$value = $rawdata['value'];
$column = $rawdata['column'];
$column = $column + 1;
$fieldname = $fields[$column];
$value = utf8_decode($value);
$query = "update $table set $fieldname = '$value' where PropID = '$id'";
$result = mysql_query($query);
if (!$result) { echo "Update failed"; }
else { echo "UPD: $value"; }
?>
When it all runs and I update a record the field Updates on the screen and shows with the "UPD:" and the entered value.
But when I check my database there is no record updated. No errors show either
How can I get the data to update in my db?
First of all, I think that this
<tr>
<?php
$planning = db::getInstance()->query('CALL sp_tobebooked()');
foreach ($planning->results() as $planning) {
?>
should be
<?php
$planning = db::getInstance()->query('CALL sp_tobebooked()');
foreach ($planning->results() as $planning) {
?>
<tr>
Then, with
"row_id": this.parentNode.getAttribute('id'),
for each td element, you select the tr element and search for the id attribute, that doesn't exists
Firstly as per rsella's comment you nee to move the row inside the loop.
Secondly as suspected you are holding the ID in a hidden cell which is infact a sibling of the editable elements rather than the parent. Try changing the table structure to the following
<tbody>
<?php
$planning = db::getInstance()->query('CALL sp_tobebooked()');
foreach ($planning->results() as $planning) {
?>
<tr id="<?php echo $planning->PropID; ?>" >
<td><?php echo $planning->ProjectNo; ?></td>
<td><?php echo $planning->Householder; ?></td>
<td><?php echo $planning->HouseNoName; ?></td>
<td><?php echo $planning->StreetName; ?></td>
<td><?php echo $planning->Postcode; ?></td>
<td><?php echo $planning->Telephone; ?></td>
<td><?php echo $planning->EPCPlanned; ?></td>
<td><?php echo $planning->TAM; ?></td>
</tr>
<?php };
?>
</tbody>
This should mean that the parent has an ID and thus this.parentNode.getAttribute('id') should be able returning the required value.
As you're only editing the EPCPlanned cell then an alternative would be
<tbody>
<?php
$planning = db::getInstance()->query('CALL sp_tobebooked()');
foreach ($planning->results() as $planning) {
?>
<tr>
<td><?php echo $planning->ProjectNo; ?></td>
<td><?php echo $planning->Householder; ?></td>
<td><?php echo $planning->HouseNoName; ?></td>
<td><?php echo $planning->StreetName; ?></td>
<td><?php echo $planning->Postcode; ?></td>
<td><?php echo $planning->Telephone; ?></td>
<td id="<?php echo $planning->PropID; ?>"><?php echo $planning->EPCPlanned; ?></td>
<td><?php echo $planning->TAM; ?></td>
</tr>
<?php };
?>
</tbody>
and in your JQuery change "row_id": this.parentNode.getAttribute('id') to this.getAttribute('id')

Load data in html table dynamically using php

I do have associative array in php (id,orderType,details) as in specified sequence.
I want to display this details in html table at runtime [while page loading]
How to achieve this? I have never done anything like this before,so please guide me. Thanks!
echo '<table>';
foreach($yourarray as $row){
echo '<tr>';
foreach($row as $key=>$cell){
echo '<td>'.$cell.'</td>';
}
echo '</tr>';
}
echo '</table>':
//detail() is your assosicative array
echo '<table><tr>';
echo '<td>id</td><td>orderType</td><td>details</td>';
echo '</tr>';
foreach($detail as $row){
echo '<tr>';
echo '<td>'.$row['id'].'</td>';
echo '<td>'.$row['orderType'].'</td>';
echo '<td>'.$row['details'].'</td>';
echo '</tr>';
}
echo '</table>';
<table>
<tr>
<td>Id</td>
<td>Order</td>
<td>Type</td>
<td>Details</td>
</tr>
<?php
$your_array = array( array('id' => 12, 'order'=>1233, 'type'=> 1233, 'details'=>2444),
array('id' => 1, 'order'=>14, 'type'=> 444, 'details'=>88));
foreach($your_array as $row){ ?>
<tr>
<td><?php echo $row['id']; ?></td>
<td><?php echo $row['order']; ?></td>
<td><?php echo $row['type']; ?></td>
<td><?php echo $row['details']; ?></td>
</tr>
<?php } ?>
</table>
$headerFlag = false;
$result = "<table border='2'>";
foreach ($array as $row){
$result = $result."<tr>";
if($headerFlag == false){
foreach($row as $key => $cell){
$result = $result."<th>".$key."</th>";
}
$headerFlag = true;
$result = $result."</tr>";
}
foreach($row as $key => $cell){
$result = $result."<td>".$cell."</td>";
}
$result = $result."</tr>";
}
echo $result = $result."</table>";

search multiple fields from a single table in php mysql

I have a table named current with several fields in that table like post, experience, company, etc.
I want to make a search having three select boxes one showing the posts from post field, 2nd showing the experience and 3rd showing the company from a single current table.
I want that if user selects from any one select field or from all it should search the respective data from the table and show the results only related to search.
For this I have written the code but its not working please help me in finding where did I went wrong, I cant understand.
It only shows data entered in post field but not in any other field.
My code goes here
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" name="">
<table>
<tr>
<?php
$ss=mysql_query("select * from current");
?>
<td><select name="post"><?php while($rr=mysql_fetch_array($ss))
{?><option value="<?php echo $rr['post'];?>"><?php echo $rr['post'];?></option><?php } ?></select></td>
<?php
$s11=mysql_query("select * from current");
?>
<td><select name="experience"><?php while($r11=mysql_fetch_array($s11))
{?><option value="<?php echo $r11['experience'];?>"><?php echo $r11['experience'];?></option><?php } ?> </select></td>
<td>
<?php
$sss=mysql_query("select * from current");
?>
<select name="company"><?php while($rrr=mysql_fetch_array($sss))
{?><option value="<?php echo $rrr['cname'];?>"><?php echo $rrr['cname'];?></option><?php } ?></select></td>
<td><input type="submit" name="search" value="Search" /></td>
</tr>
</table>
</form>
my search code goes here
<?php
include('Admin/config.php');
error_reporting(E_ERROR | E_WARNING | E_PARSE);
if(isset($_REQUEST['search']))
{
$post = $_REQUEST['post'];
$ex = $_REQUEST['experience'];
$company = $_REQUEST['company'];
$query = "select * from current where post like '%$post%' or experience like '%$ex%' or cname like '%$company%' ";
$res1 = mysql_query($query);
while($rows = mysql_fetch_array($res1))
{
?>
<tr>
<td><?php echo $rows['date'];?></td>
<td><?php echo $rows['post'];?></td>
<td><?php echo $rows['qualification'];?></td>
<td><?php echo $rows['experience'];?></td>
<td><?php echo $rows['nop'];?></td>
<td><?php echo $rows['noj'];?></td>
<td><?php echo $rows['cname'];?></td>
<td><?php echo $rows['jloc'];?></td>
</tr><?php
}}
else
{
$s=mysql_query("SELECT * FROM current ORDER BY date DESC");
while($rows=mysql_fetch_array($s))
{
?>
<tr>
<td><?php echo $rows['date'];?></td>
<td><?php echo $rows['post'];?></td>
<td><?php echo $rows['qualification'];?></td>
<td><?php echo $rows['experience'];?></td>
<td><?php echo $rows['nop'];?></td>
<td><?php echo $rows['noj'];?></td>
<td><?php echo $rows['cname'];?></td>
<td><?php echo $rows['jloc'];?></td>
</tr>
<?php
}}
?>
</table>
<?php
include('Admin/config.php');
error_reporting(E_ERROR | E_WARNING | E_PARSE);
$ss=mysql_query("select `post`,`experience`,`cname` from current");
$filter = array();
while($rr = mysql_fetch_assoc($ss)) {
foreach ($rr as $key => $val) {
$filter[$key][] = $val;
}
}
$request = array('post' => '', 'experience' => '', 'cname' => '');
if (isset($_REQUEST['search']))
{
$request = array(
'post' => $_REQUEST['post'],
'experience' => $_REQUEST['experience'],
'cname' => $_REQUEST['cname'],
);
}
?>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" name="">
<table>
<tr>
<?php
foreach ($filter as $name => $value) {
?>
<td>
<select name="<?=$name?>">
<?
foreach ($value as $key => $val) {
?>
<option value="<?=$val?>"<?= $val === $request[$name] ? ' selected' : ''?>><?=$val?></option>
<?
}
?>
</select>
</td>
<?
}
?>
<td><input type="submit" name="search" value="Search" /></td>
</tr>
</table>
</form>
<table>
<?php
if(isset($_REQUEST['search']))
{
$where = '';
foreach ($request as $key => $val) {
if ($where !== '') {
$where .= ' OR ';
}
$where .= "`".$key."` like '%".$val."%' ";
}
$query = "select * from current where ".$where;
}
else
{
$query = "select * from current ORDER BY date DESC";
}
$res1 = mysql_query($query);
while($rows=mysql_fetch_array($res1))
{
?>
<tr>
<td><?php echo $rows['date'];?></td>
<td><?php echo $rows['post'];?></td>
<td><?php echo $rows['qualification'];?></td>
<td><?php echo $rows['experience'];?></td>
<td><?php echo $rows['nop'];?></td>
<td><?php echo $rows['noj'];?></td>
<td><?php echo $rows['cname'];?></td>
<td><?php echo $rows['jloc'];?></td>
</tr>
<?php
}
?>
</table>

Display query result in a table

I have a MySQL query with over 50 return results. Now I need to display the results in a table with 3 rows and 3 columns.
Something like this:
<table>
<tr>
<td>Content</td>
<td>Content</td>
<td>Content</td>
</tr>
<tr>
<td>Content</td>
<td>Content</td>
<td>Content</td>
</tr>
<tr>
<td>Content</td>
<td>Content</td>
<td>Content</td>
</tr>
</table>
I tried it with PHP like this:
$q = "SELECT name, address, content FROM mytable";
$r = mysqli_query($dbc, $q);
while ($row = mysqli_fetch_array($r, MYSQLI_ASSOC)) {
$name = $row['name'];
$address = $row['address'];
$content = $row['content'];
//Create new output
$output = "<p>$name</p>";
$output .= "<p>$address</p>";
$output .= "<p>$content</p>";
//Add output to array
$mycontent[] = $output;
}
Then I am printing the content array in my table like this:
<tr>
<td><?php echo $mycontent[0]; ?></td>
<td><?php echo $mycontent[1]; ?></td>
<td><?php echo $mycontent[2]; ?></td>
</tr>
<tr>
<td><?php echo $mycontent[3]; ?></td>
<td><?php echo $mycontent[4]; ?></td>
<td><?php echo $mycontent[5]; ?></td>
</tr>
<tr>
<td><?php echo $mycontent[6]; ?></td>
<td><?php echo $mycontent[7]; ?></td>
<td><?php echo $mycontent[8]; ?></td>
</tr>
Using this code, I can only display 9 contents. My problem is that I want to display more content. I'm going to use pagination to display contents; something like 0-9, 10-18, 19-27 etc.
NOTE: I can do the pagination part.
I hope someone will give me the right direction for this.
Thank you.
try something like:
echo "<table>";
while ($row = mysqli_fetch_array($r, MYSQLI_ASSOC)) {
$name = $row['name'];
$address = $row['address'];
$content = $row['content'];
echo "<tr><td>".$name."</td><td>".$address."</td><td>".$content."</td></tr>";
}
echo "</table>";
this example will print in table all the result of the query.
if you want to limit only to some results, so limit the sql query.
for example:
$q = "SELECT name, address, content FROM mytable limit 50";
to get each content,name, address in TD, and 3 of mycontent(content, name, address) in a TR try this:
$c= mysql_query("select COUNT(name) from mytable");
$n=mysql_fetch_array($c);
$maxname= $n[0];
$i=0;
$tr=0;
echo "<table>";
while ($tr < $maxname)
{
echo "<tr>";
while ($row = mysqli_fetch_array($r, MYSQLI_ASSOC) and $i<$tr) {
$name = $row['name'];
$address = $row['address'];
$content = $row['content'];
echo "<td>".$name." | ".$address." | ".$content."</td>";
$i++;
}
echo "</tr>";
$tr= $tr+3;
}
echo "</table>";
Try something like this. It places your values in an easy to use associative array. Then you just loop through.
<?php
while ($row = mysqli_fetch_array($r, MYSQLI_ASSOC)) {
$values[] = array(
'name' => $row['name'],
'address' => $row['address'],
'content' => $row['content']
);
}
?>
<table>
<?php
foreach($values as $v){
echo '
<tr>
<td>'.$v['name'].'</td>
<td>'.$v['address'].'</td>
<td>'.$v['content'].'</td>
</tr>
';
}
?>
</table>
You can store in a variable if u r planning to use it in a function or you can just print it. Either way...
$q = "SELECT name, address, content FROM mytable";
$r = mysqli_query($dbc, $q);
$str = "<table>";
while ($row = mysqli_fetch_array($r, MYSQLI_ASSOC)) {
$str .= "<tr>";
$str .= "<td>" . $row['name'] . "</td>";
$str .= "<td>" . $row['address'] . "</td>";
$str .= "<td>" . $row['content'] . "</td>";
$str .= "</tr>";
}
$str .= "</table>"
echo $str;
There you go!
use a for-loop to iterate your $mycontent-array:
EDIT: I was made aware that $mycontent is built differently than I first assumed:
$h = "<table>"; // we are going to build the table in $h
$maxcount = count($mycontent); // get the number of values within the array
for ($i = 0;$i < $maxcount;$i++) { // counting $i up from 0 to $maxcount -1 ...
$h.= "<tr><td>{$mycontent[$i]}</td></tr>"; // build row
}
$h.= "</table>"; // close the table
echo $h; // echo it
---> live demo: http://3v4l.org/g1E1T
YOU CAN REFERENCE THIS CODE
<tbody>
<!-- <tr>
<td>Technology</td>
<td>Professor Abiola</td>
<td>wetech#school.com</td>
<td> Plot 2, Oriola road,</td>
<td>
<button type="button" class="btn btn-primary"> Edit</button>
<button type="button" class="btn btn-success">Update</button>
<button type="button" class="btn btn-danger">Delete</button>
</td>
</tr> -->
<?php
while($rows = mysqli_fetch_array($response)){
$faculty = $rows['faculty'];
$hod = $rows['hod'];
$email = $rows['email'];
// $location = $rows['location'];
echo "<tr>
<td>$faculty</td>
<td>$hod</td>
<td>$email</td>
<td>".$rows["location"]."</td>
<td>
<button type='button' class='btn btn-primary'>Edit</button>
<button type='button' class='btn btn-success'>Update</button>
<button type='button' class='btn btn-danger'>Delete</button>
</td>
</tr>";
}
?>
</tbody>
</table>

Categories