So, i have this code that returns me a simple table with the correct db values:
<?php
echo "<table border='1'>
<tr>
<th>Código</th>
<th>Nome</th>
<th>Indicou</th>
</tr>";
while($coluna_bd_tabela = mysqli_fetch_array($sql_indicador_resul)){
echo "<tr>";
echo "<td>" . $coluna_bd_tabela['usu_codigo'] . "</td>";
echo "<td>" . $coluna_bd_tabela['usu_nome'] . "</td>";
echo "<td>" . $coluna_bd_tabela['usu_indicador_codigo'] . "</td>";
echo "</tr>";
}
echo "</table>";
?>
And this one is the stylized table without the querys working:
<table class="table table-striped projects">
<thead>
<tr>
<th style="width: 1%">#</th>
<th style="width: 20%">Nome</th>
<th>Membros Recentes</th>
<th>Project Progress</th>
<th>Status</th>
<th style="width: 20%">#Edit</th>
</tr>
</thead>
<tbody>
<tr>
<td>echo $coluna_bd_tabela['usu_codigo']</td>
<td>
<a> echo $coluna_bd_tabela['usu_nome']</a>
<br />
<small>echo $coluna_bd_tabela['usu_indicou']</small>
</td>
<td>
<ul class="list-inline">
<li>
<img src="images/user.png" class="avatar" alt="Avatar">
</li>
<li>
<img src="images/user.png" class="avatar" alt="Avatar">
</li>
<li>
<img src="images/user.png" class="avatar" alt="Avatar">
</li>
<li>
<img src="images/user.png" class="avatar" alt="Avatar">
</li>
</ul>
</td>
<td class="project_progress">
<div class="progress progress_sm">
<div class="progress-bar bg-green" role="progressbar" data-transitiongoal="57"></div>
</div>
<small>57% Complete</small>
</td>
<td>
<button type="button" class="btn btn-success btn-xs">Success</button>
</td>
<td>
<i class="fa fa-folder"></i> View
<i class="fa fa-pencil"></i> Edit
<i class="fa fa-trash-o"></i> Delete
</td>
</tr>
</tbody>
I want to show the stylized table with the values of the querys, but this is destroying me. The database connection is fine, these are the querys on a include connection, they are working fine too, as have been shown on the simple table:
$sql_indicador = "SELECT * FROM esc_usuarios WHERE usu_indicador_codigo = '" . $_SESSION['codigo'] . "'";
$sql_indicador_resul = mysqli_query($conexao, $sql_indicador);
To provide a full solution:
<table class="table table-striped projects">
<thead>
<tr>
<th style="width: 1%">#</th>
<th style="width: 20%">Nome</th>
<th>Membros Recentes</th>
<th>Project Progress</th>
<th>Status</th>
<th style="width: 20%">#Edit</th>
</tr>
</thead>
<?php while($coluna_bd_tabela = mysqli_fetch_array($sql_indicador_resul)){ ?>
<tbody>
<tr>
<td><?php echo $coluna_bd_tabela['usu_codigo']; ?></td>
<td>
<a><?php echo $coluna_bd_tabela['usu_nome']; ?></a>
<br />
<small><?php echo $coluna_bd_tabela['usu_indicou']; ?></small>
</td>
<td>
<ul class="list-inline">
<li>
<img src="images/user.png" class="avatar" alt="Avatar">
</li>
<li>
<img src="images/user.png" class="avatar" alt="Avatar">
</li>
<li>
<img src="images/user.png" class="avatar" alt="Avatar">
</li>
<li>
<img src="images/user.png" class="avatar" alt="Avatar">
</li>
</ul>
</td>
<td class="project_progress">
<div class="progress progress_sm">
<div class="progress-bar bg-green" role="progressbar" data-transitiongoal="57"></div>
</div>
<small>57% Complete</small>
</td>
<td>
<button type="button" class="btn btn-success btn-xs">Success</button>
</td>
<td>
<i class="fa fa-folder"></i> View
<i class="fa fa-pencil"></i> Edit
<i class="fa fa-trash-o"></i> Delete
</td>
</tr>
</tbody>
<?php } ?>
</table>
You forgot to use the <?php and ?> opening and closing tags around the echo statements. Furthermore, you missed the ; at the end of each statement. I've also moved the beginning and the end of the table out of PHP's echo since I believe it looks much clearer this way.
Related
Currently I have a <a href> tag that is referencing one of my div tags by using href=#work to switch the table to that particular div when clicked on. But this doesnt change my view when I click on the particular div tag. It just changes my URL from http://localhost/contacts/view/1 to http://localhost/contacts/view/1#work when I click on it for some reason.
My code:
<ul class="nav nav-tabs">
<li role="presentation" class="active">Personal</li>
<li role="presentation">Work</li>
</ul>
<div class="tab-content">
<div role="tabpanel" class="tab-pane fade in active" id="personal">
<table class="table table-hover m-b-0">
<tbody>
<tr>
<td width="20%" class="noborder">Mobile</td>
<td width="30%" class="noborder active"><i class="fa fa-mobile"></i> <?php echo $details['personal']['mobile'] ?></td>
<td width="20%" class="noborder">Phone</td>
<td class="active noborder"><i class="fa fa-phone"></i> <?php echo $details['personal']['phone'] ?></td>
</tr>
</tbody>
</table>
</div>
<div role="tabpanel" class="tab-pane fade" id="work">
<table class="table table-hover m-b-0">
<tbody>
<tr>
<td width="20%" class="noborder">Mobile</td>
<td width="30%" class="noborder active"><i class="fa fa-mobile"></i> <?php echo $details['work']['mobile'] ?></td>
<td class="noborder" width="20%">Phone</td>
<td class="active noborder"><i class="fa fa-phone"></i> <?php echo $details['work']['phone'] ?></td>
</tr>
</tbody>
</table>
</div>
</div>
This also got me - provided you are using Bootstrap (4.1.3). Tab Panels using the nav tabs, the <a> tags need to have the class nav-link. Here's adding the classes nav-item and nav-link to the markup:
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js" integrity="sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js" integrity="sha384-ChfqqxuZUCnJSK3+MXmPNIyE6ZbWh2IMqE241rYiqJxyMiZ6OW/JmZQ5stwEULTy" crossorigin="anonymous"></script>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
<ul class="nav nav-tabs">
<li role="presentation" class="active nav-item">Personal</li>
<li role="presentation" class="nav-item">Work</li>
</ul>
<div class="tab-content">
<div role="tabpanel" class="tab-pane fade show active" id="personal">
<table class="table table-hover m-b-0">
<tbody>
<tr>
<td width="20%" class="noborder">Mobile</td>
<td width="30%" class="noborder active"><i class="fa fa-mobile"></i> 555-555-5555</td>
<td width="20%" class="noborder">Phone</td>
<td class="active noborder"><i class="fa fa-phone"></i> 555-555-5555</td>
</tr>
</tbody>
</table>
</div>
<div role="tabpanel" class="tab-pane" id="work">
<table class="table table-hover m-b-0">
<tbody>
<tr>
<td width="20%" class="noborder">Mobile</td>
<td width="30%" class="noborder active"><i class="fa fa-mobile"></i> 333-333-3333</td>
<td width="20%" class="noborder">Phone</td>
<td class="active noborder"><i class="fa fa-phone"></i> 333-333-3333</td>
</tr>
</tbody>
</table>
</div>
</div>
This is my table body.....
<section class="content">
<div class="row">
<div class="col-12">
<div class="card">
<div class="card-header">
<h3 class="card-title"></h3>
</div>
<!-- /.card-header -->
<div class="card-body">
<table id="example1" class="table table-bordered table-striped">
<thead>
<tr>
<th>Category ID</th>
<th>Category Image</th>
<th>Category Name</th>
<th>Edit</th>
<th>Delete</th>
</tr>
</thead>
<tbody>
<?php
$sql = "SELECT * FROM `categories`";
$res_data = mysqli_query($con, $sql);
while ($row = mysqli_fetch_assoc($res_data)) {
// code...
?>
<tr>
<td><?php echo $row['Category_ID']; ?></td>
<td><?php echo "<img src=\"data:image;base64," . $row['Category_Image_Temp'] . "\" alt=" . $row['Category_Image_Name'] . " width=\"50px\" height=\"50px\">"; ?></td>
<td><?php echo $row['Category_Name']; ?></td>
<td><textarea><?php echo $row['Category_Name']; ?></textarea></td>
<td><a class="btn btn-info btn-sm" href="#">
<i class="fas fa-pencil-alt">
</i>
Update
</a></td>
<td><a class="btn btn-danger btn-sm" href="#">
<i class="fas fa-trash">
</i>
Delete
</a></td>
</tr>
<?php
}
?>
</tbody>
<tfoot>
<tr>
<th>Category ID</th>
<th>Category Image</th>
<th>Category Name</th>
<th>Edit</th>
<th>Delete</th>
</tr>
</tfoot>
</table>
</div>
<!-- /.card-body -->
</div>
<!-- /.card -->
</div>
<!-- /.col -->
</div>
<!-- /.row -->
</section>
So when I remove <td><?php echo "<img src=\"data:image;base64," . $row['Category_Image_Temp'] . "\" alt=" . $row['Category_Image_Name'] . " width=\"50px\" height=\"50px\">"; ?></td> this line from the code, then only the pagination and search appears.
Main issue is when I display images in the datatables the pagination and search doesn't appears.
I want to display pagination and search when I display images in datatables.
Anybody can help?
Thanks....
I have one table and in this table, I have two button Update and Disable I want to hide those buttons
I trying like this
<table id="example1" class="table table-bordered table-striped table-sm" style=" overflow: auto; ">
<tr>
<th>Dispatch Challan No</th>
<th>Date</th>
<th>From</th>
<?php
$hide = 'OFF';
if($hide == 'ON') { ?>
<th>Update</th>
<th>Delete</th>
<?php } ?>
</tr>
<?php foreach($dispatch as $dis){?>
<tr>
<td><?php echo $dis->disp_ch_no;?></td>
<td><?php echo date("d-m-Y", strtotime($dis->disp_ch_date));?></td>
<td><?php echo $dis->from_branch_name;?></td>
<td><a class="btn btn-success btn-sm" href="<?php echo base_url(); ?>booking/dispatch_challan/DispatchChallanController/updateDispatchChallanPage?disp_id=<?php echo $dis->disp_id; ?>"><i class="fa fa-pencil" > Update</i></a></td>
<td><a class="btn btn-danger btn-sm" onclick="delete_dispatch('<?php echo $dis->disp_id; ?>');" title="Click here to delete your Dispatch record"><i class="fa fa-trash" style="color: #fff;"> Disable </i> </a>
</td>
</tr>
<?php }?>
</table>
this is my table
How can I hide these buttons
Try this,
<?php
$thswitch = 'OFF';
if($thswitch == 'ON') { ?>
<th>Update</th>
<th>Delete</th>
<?php } ?>
whenever you want to show just $thswitch = 'ON'; it
You have to check the if () for each row as we did in th. Like:
<table id="example1" class="table table-bordered table-striped table-sm" style="overflow: auto;">
<tr>
<th>Dispatch Challan No</th>
<th>Date</th>
<th>From</th>
<?php $hide = 'OFF';
if ($hide == 'ON') { ?>
<th>Update</th>
<th>Delete</th>
<?php } ?>
</tr>
<?php foreach($dispatch as $dis) { ?>
<tr>
<td> <?php echo $dis->disp_ch_no;?> </td>
<td> <?php echo date("d-m-Y", strtotime($dis->disp_ch_date));?> </td>
<td> <?php echo $dis->from_branch_name;?> </td>
<?php if ($hide == 'ON') { ?>
<td>
<a class="btn btn-success btn-sm" href="<?php echo base_url(); ?>booking/dispatch_challan/DispatchChallanController/updateDispatchChallanPage?disp_id=<?php echo $dis->disp_id; ?>"><i class="fa fa-pencil" > Update</i></a>
</td>
<td>
<a class="btn btn-danger btn-sm" onclick="delete_dispatch('<?php echo $dis->disp_id; ?>');" title="Click here to delete your Dispatch record"><i class="fa fa-trash" style="color: #fff;"> Disable </i> </a>
</td>
<?php } ?>
</tr>
<?php } ?>
</table>
Or by using CSS you can hide this columns as:
Create a CSS class like:
.hidethisColumn { display: none !important; }
Use it in you table as:
<th class="<?=(($hide == 'ON')? 'hidethisColumn' : '')?>">Update</th>
<th class="<?=(($hide == 'ON')? 'hidethisColumn' : '')?>">Delete</th>
Similarly in rows inside foreach():
<td class="<?=(($hide == 'ON')? 'hidethisColumn' : '')?>">
<a class="btn btn-success btn-sm" href="<?php echo base_url(); ?>booking/dispatch_challan/DispatchChallanController/updateDispatchChallanPage?disp_id=<?php echo $dis->disp_id; ?>"><i class="fa fa-pencil" > Update</i></a>
</td>
how to give the spacing between each cell in a table and make it like a different making a table in HTML.
i want to make it like a cells becoming table by combining it all together.
code:
like shown tabs in the www.quickr.com
<table class="table" width=100% cellspacing="3px" style="border-spacing:10px; ">
<tr>
<!--<td bgcolor="#FF0000">-->
<!--<td bgcolor="#F3E9AF" height="200px" width="350px" style="padding: 74px;">-->
<td style="padding: -7px;">
<!--<td bgcolor="#99E7F7">-->
<div class="column col-md-4">
<div id="c-830" class="block">
<h4><img src="images/categories/rent_7.png" height=110 width=150 style="margin-top: -5px">
<a href="#">
<strong style="color: #343434;">Rent</strong>
</a>
</h4>
<div>
</div>
</div>
</div>
</td>
<td style="padding: -35px;">
<!--<td bgcolor="#004488">-->
<div class="column col-md-4">
<div id="c-362" class="block">
<h4><img src="images/categories/buy_6.png" height=110 width=150 style="margin-top: -3px">
<a href="#">
<strong style="color: #343434;">Buy</strong>
</a>
</h4>
<div>
</div>
</div> </div>
</td>
<td style="padding: -23px;">
<div class="column col-md-4">
<div id="c-833" class="block">
<h4><img src="images/categories/sell_tag.png" height=110 width=150 style="margin-top: -5px">
<a href="#">
<strong style="color: #343434;">Sell</strong>
</a>
</h4>
<div>
</div>
</div>
</div>
</td>
</tr>
</table>
Try to give a table name and then you could add for td/tr in css a padding or border-spacing.
Try this .. by using cellpadding="value" & cellspacing="value"
Check this: Fiddle Demo
Try this .. by using
<table cellpadding="15" cellspacing="15">
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
</tr>
<tr>
<td>4</td>
<td>5</td>
<td>6</td>
</tr>
</table>
I am trying to make a user profile page system, but when I have a while, or foreach inside of a while, or foreach it doesn't execute any of the code inside, and after the loop.
foreach($db->query("SELECT * FROM `members` WHERE username = '$user'") as $row) {
echo "
<div class='page-header'>
<div class='row'>
<div class='span12'>
<div class='tabbable'>
<ul class='nav nav-tabs'>
<li class='active'>
<a data-toggle='tab' href='#about'>About $user</a>
</li>
<li>
<a data-toggle='tab' href='#infractions'>Infractions</a>
</li>
</ul>
<div class='tab-content' style='overflow: visible;'>
<div class='tab-pane active' id='about'>
<div class='row'>
<div class='span9'>
<div class='span4' style='float:left; width:25%'>
".$row['reputation']."
</div>
</div>
</div>
<div class='tab-pane' id='infractions'>
<div class='row'>
<div class='span12'>
<br>
<h3>Received Infractions</h3>
<table class='table table-bordered table-striped'>
<thead>
<tr>
<th width='13%'>Issuer</th>
<th width='13%'>Punished</th>
<th width='34%'>Reason</th>
<th width='7%'>Type</th>
<th width='7%'>Status</th>
<th width='9%'>Expires</th>
<th width='12%'>Date</th>
</tr>
</thead>
<tbody>
<tr class=''>";
//foreach($db->query("SELECT * FROM `infractions` WHERE reciver = '$user'") as $infraction) {
$stmt = $db->query("SELECT * FROM `infractions` WHERE reciver = '$user'");
while($infraction = $stmt->fetch(PDO::FETCH_ASSOC)) {
echo "<td><a href='/profiles/".$infraction['issuer']."' style='color: #F55'>".$infraction['issuer']."</a></td>
<td><a href='/profiles/".$infraction['reciver']."'>".$infraction['reciver']."</a></td>
<td>".$infraction['reason']."</td>
<td style='color:";
if($infraction['type']=="ban"){echo "red";}
elseif($infraction['type']=="tempban"){echo "orange";}
elseif($infraction['type']=="kick"){echo "yellow";}
elseif($infraction['type']=="mute"){echo "blue";}
echo "'>";
if($infraction['type']=="ban"){echo "Ban";}
elseif($infraction['type']=="tempban"){echo "Tempban";}
elseif($infraction['type']=="kick"){echo "Kick";}
elseif($infraction['type']=="mute"){echo "Mute";}
echo "</td><td><span style='color:";
if($infraction['appstatus']=="0"){echo "N/A";}
elseif($infraction['appstatus']=="1"){echo "black";}
elseif($infraction['appstatus']=="2"){echo "blue";}
elseif($infraction['appstatus']=="3"){echo "red";}
elseif($infraction['appstatus']=="4"){echo "green";}
echo "orange";
echo "'>";
if($infraction['appstatus']=="0"){echo "N/A";}
elseif($infraction['appstatus']=="1"){echo "Not Appealed";}
elseif($infraction['appstatus']=="2"){echo "Appeal Pending";}
elseif($infraction['appstatus']=="3"){echo "Appeal Rejected";}
elseif($infraction['appstatus']=="4"){echo "Appeal Accepted";}
echo"</span>
</td>
<td>
Never
</td>
<td data-container='body' data-placement='left' rel='tooltip' title='' data-original-title='January 4th, 2014 - 6:20 PM'>
<a href='/infractions/52c8a54fc8f2382195d7b3c4'>
17 minutes
ago
</a>";
}
echo "</td>
</tr>
</tbody>
</table>
</section>
</section>";
(ignore the unmatched {} errors, as I didn't spend a lot of time shortening it, also I can connect to the database, I just didn't include it.)
I don't get any errors, and everything before the second foreach works fine.